私のアプリケーションで写真を撮ってイメージパスを取得しようとしています。私はACTION_IMAGE_CAPTUREを使って写真を撮影し、画像パスを取得できますが、実行時例外も発生します。ここに私のコードは次のとおりです。Android ACTION_IMAGE_CAPTURE結果ランタイム例外の配信に失敗しました
スタートカメラの意図:
public void openDeviceCam() {
// Setting parameters to camera intent
String fileName = String.valueOf(System.currentTimeMillis()) + ".jpg";
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.TITLE, fileName);
mCapturedImageURI = getContentResolver().insert(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
Intent cameraIntent = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI);
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
}
カメラ活動から生じる取得:
// Returns after photo taken by phone
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if ((resultCode == RESULT_OK) && (requestCode == CAMERA_PIC_REQUEST)) {
DataHandler handler = DataHandler.getInstance();
// Photo taken
imageCount++;
handleUICompanents();
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(mCapturedImageURI, projection, null,
null, null);
int column_index_data = cursor
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
String capturedImageFilePath = cursor.getString(column_index_data);
// Getting path datas to memory
Log.v("captured image path", capturedImageFilePath);
handler.setImagePathsToList(capturedImageFilePath);
ConnectionHandler connectionHandler = new ConnectionHandler();
// Calculate passed time during post
long startSec = System.currentTimeMillis();
// Reques 2
StringBuilder strBuild = new StringBuilder();
strBuild.append(UrlConstants.swfUrl)
.append(UrlConstants.swfUrlParamsUploadType)
.append("image_").append(handler.getSite()).append("_")
.append(handler.getDomain());
String respDataToImage = connectionHandler.postImageAsData(
strBuild.toString(), handler.getImagePath());
handler.setUpSwfUploadResponseParams(respDataToImage);
long finishSec = System.currentTimeMillis();
// Request 3
strBuild = new StringBuilder();
strBuild.append(UrlConstants.savePhotoUrl)
.append(UrlConstants.savePhotoUrlParamsSt)
.append(handler.getSt()).append("&")
.append(UrlConstants.savePhotoUrlParamsAlbum)
.append(handler.getPath()).append("&")
.append(UrlConstants.savePhotoUrlParamsUploadedPhotoHash)
.append(handler.getUploadKey()).append("&")
.append(UrlConstants.savePhotoUrlParamsCdnDomain)
.append(UrlConstants.cdnDomain).append("&")
.append(UrlConstants.savePhotoUrlParamsAppId)
.append(handler.getSite()).append("&")
.append(UrlConstants.savePhotoUrlParamsNetmeraDomain)
.append(handler.getDomain()).append("&")
.append(UrlConstants.savePhotoUrlParamsViewerId)
.append(handler.getOpensocialViewerId()).append("&");
connectionHandler.getData(strBuild.toString(), null);
Log.v("passed time", String.valueOf(finishSec - startSec));
Log.v("upload path", handler.getPath());
// Delete temp image path
// deleteTempImages();
}
}
そして、ここでは私のlogcatエラー出力です:
11-12 14:43:10.469: ERROR/AndroidRuntime(20850): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1337, result=-1, data=null} to activity {com.inomera.ttmobilerehber/com.inomera.ttmobilerehber.TTMobileRehberActivity}: java.lang.NullPointerException: println needs a message
11-12 14:43:10.469: ERROR/AndroidRuntime(20850): at android.app.ActivityThread.deliverResults(ActivityThread.java:2536)
11-12 14:43:10.469: ERROR/AndroidRuntime(20850): at android.app.ActivityThread.handleSendResult(ActivityThread.java:2578)
11-12 14:43:10.469: ERROR/AndroidRuntime(20850): at android.app.ActivityThread.access$2000(ActivityThread.java:117)
11-12 14:43:10.469: ERROR/AndroidRuntime(20850): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:965)
11-12 14:43:10.469: ERROR/AndroidRuntime(20850): at android.os.Handler.dispatchMessage(Handler.java:99)
11-12 14:43:10.469: ERROR/AndroidRuntime(20850): at android.os.Looper.loop(Looper.java:123)
11-12 14:43:10.469: ERROR/AndroidRuntime(20850): at android.app.ActivityThread.main(ActivityThread.java:3687)
11-12 14:43:10.469: ERROR/AndroidRuntime(20850): at java.lang.reflect.Method.invokeNative(Native Method)
11-12 14:43:10.469: ERROR/AndroidRuntime(20850): at java.lang.reflect.Method.invoke(Method.java:507)
11-12 14:43:10.469: ERROR/AndroidRuntime(20850): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
11-12 14:43:10.469: ERROR/AndroidRuntime(20850): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
11-12 14:43:10.469: ERROR/AndroidRuntime(20850): at dalvik.system.NativeStart.main(Native Method)
11-12 14:43:10.469: ERROR/AndroidRuntime(20850): Caused by: java.lang.NullPointerException: println needs a message
11-12 14:43:10.469: ERROR/AndroidRuntime(20850): at android.util.Log.println_native(Native Method)
11-12 14:43:10.469: ERROR/AndroidRuntime(20850): at android.util.Log.v(Log.java:116)
11-12 14:43:10.469: ERROR/AndroidRuntime(20850): at com.inomera.ttmobilerehber.TTMobileRehberActivity.onActivityResult(TTMobileRehberActivity.java:155)
11-12 14:43:10.469: ERROR/AndroidRuntime(20850): at android.app.Activity.dispatchActivityResult(Activity.java:3908)
11-12 14:43:10.469: ERROR/AndroidRuntime(20850): at android.app.ActivityThread.deliverResults(ActivityThread.java:2532)
11-12 14:43:10.469: ERROR/AndroidRuntime(20850): ... 11 more
11-12 14:43:10.489: ERROR/(162): Dumpstate > /data/log/dumpstate_app_error
これを試す:http://stackoverflow.com/questions/8248327/my-android-camera-uri-is-returning-a-null-value-but-the-samsung-fix-is-in-place – Bush