在我的应用程序中,我使用Android设备相机捕获我的图像.在某些设备上它工作正常,但不是全部,我只是测试了LG nexus 5 E960,在我捕获图像后它总是结束崩溃而无法保存结果这是我的代码:
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, 1);
protected void onActivityResult(int requestCode, int resultCode,
Intent returnimage) {
super.onActivityResult(requestCode, resultCode, returnimage);
switch (requestCode) {
case 1:
if (resultCode == RESULT_OK) {
Uri selectedImage = returnimage.getData();
String stringUri;
stringUri = selectedImage.toString();
Intent i1 = new Intent(MainActivity.this, Secondpage.class);
i1.putExtra("Stringuri",stringUri );
startActivity(i1);
}
break;
Run Code Online (Sandbox Code Playgroud)
我的logcat是:
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null,
request=1, result=-1, data=Intent { act=inline-data (has extras) }} to activity
{com.photostikers/com.photostikers.MainActivity}: java.lang.NullPointerException
02-13 12:27:54.315: E/AndroidRuntime(28759): at
android.app.ActivityThread.deliverResults(ActivityThread.java:3365)
02-13 12:27:54.315: E/AndroidRuntime(28759): at …
Run Code Online (Sandbox Code Playgroud) 我试图在来电屏幕上添加弹出窗口作为真正的调用者但无法实现.我知道这背后的逻辑是什么以及我如何实现这一点
public void onReceive(Context context, Intent intent) {
try {
// TELEPHONY MANAGER class object to register one listner
TelephonyManager tmgr = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
}
} catch (Exception e) {
Log.e("Phone Receive Error", " " + e);
}
}
Run Code Online (Sandbox Code Playgroud) android ×2