我正在开发一个带有嵌入式二维码阅读器的应用程序,在扫描代码之后,我必须使用从二维码中获取的参数启动另一个活动(名为 CodaActivity.class)。
我从此处找到的教程开始:( https://www.androidtutorialonline.com/android-qr-code-scanner/ ) 并尝试根据我的需要对其进行自定义。
这是 QRCodeScannerActivity 的代码:
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import andoid.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.Toast;
import com.google.zxing.Result;
import me.dm7.barcodescanner.zxing.ZXingScannerView;
import static android.Manifest.permission.CAMERA;
public class QrCodeScannerActivity extends AppCompatActivity implements ZXingScannerView.ResultHandler {
private static final int REQUEST_CAMERA = 1;
private ZXingScannerView mScannerView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mScannerView = new ZXingScannerView(this);
setContentView(mScannerView);
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= android.os.Build.VERSION_CODES.M) {
if (checkPermission()) {
Toast.makeText(getApplicationContext(), "Permission already granted", Toast.LENGTH_LONG).show();
} else {
requestPermission();
}
}
}
}
}
但是在我扫描二维码后(当然是用物理设备),调试器退出并显示以下消息:
I/art: Object allocation is busy now, so prior to grow the heap. New heap size is 33 MB
I/art: current process_level is : 0
I/art: current process_level is : 0
I/art: current process_level is : 0
I/art: current process_level is : 0
I/art: current process_level is : 0
I/Process: Sending signal. PID: 8310 SIG: 9
Application terminated.
手机中的应用程序仍然保持运行状态,但会进行不同的活动。为什么?以及为什么我没有错误!感谢您的回答
隔江千里
交互式爱情
相关分类