Intent を使用してアプリケーションで写真をキャプチャしています:
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
しかし、写真をキャプチャして [保存] ボタンをクリックすると、次のエラーがスローされます。
liblog failed to call dumpstate
AndroidRuntime java.lang.NullPointerException
AndroidRuntime at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1210)
AndroidRuntime at android.widget.TableRow.onLayout(TableRow.java:121)
AndroidRuntime at android.view.View.layout(View.java:7175)
AndroidRuntime at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
AndroidRuntime at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
AndroidRuntime at android.widget.TableLayout.onLayout(TableLayout.java:440)
AndroidRuntime at android.view.View.layout(View.java:7175)
AndroidRuntime at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
AndroidRuntime at android.widget.ScrollView.onLayout(ScrollView.java:1565)
AndroidRuntime at android.view.View.layout(View.java:7175)
AndroidRuntime at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
AndroidRuntime at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
AndroidRuntime at android.widget.LinearLayout.onLayout(Lin1earLayout.java:1047)
AndroidRuntime at android.view.View.layout(View.java:7175)
AndroidRuntime at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
AndroidRuntime at android.view.View.layout(View.java:7175)
AndroidRuntime at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
AndroidRuntime at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
AndroidRuntime at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
AndroidRuntime at android.view.View.layout(View.java:7175)
AndroidRuntime at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
AndroidRuntime at android.view.View.layout(View.java:7175)
AndroidRuntime at android.view.ViewRoot.performTraversals(ViewRoot.java:1146)
AndroidRuntime at android.view.ViewRoot.handleMessage(ViewRoot.java:1865)
AndroidRuntime at android.os.Handler.dispatchMessage(Handler.java:99)
AndroidRuntime at android.os.Looper.loop(Looper.java:130)
AndroidRuntime at android.app.ActivityThread.main(ActivityThread.java:3687)
AndroidRuntime at java.lang.reflect.Method.invokeNative(Native Method)
AndroidRuntime at java.lang.reflect.Method.invoke(Method.java:507)
AndroidRuntime at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
AndroidRuntime at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
AndroidRuntime at dalvik.system.NativeStart.main(Native Method)
Dumpstate > /data/log/dumpstate_app_error
しかし、このアプリケーションを別のモバイルで使用すると、完全に機能します。何が問題なのかわからない。
写真をキャプチャした後のコード:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
try {
if (requestCode == CAMERA_REQUEST) {
Bitmap bitmap = (Bitmap) data.getExtras().get("data");
imageViewPhoto.setImageBitmap(bitmap);
}
} catch (NullPointerException e) {
Toast.makeText(this, "Problem while capturing photo. Try after some time.", Toast.LENGTH_LONG).show();
}
}