2017-01-27 11 views
-2

私のアプリケーションから画像を作成しようとしています。私はカメラを起動して写真を撮ることができますが、写真が終わるとアプリがクラッシュします。私の画面で私のGaleryが停止していることがわかります。これはログのエラーです。Intentを処理するためのアクティビティが見つかりませんcom.android.camera.action.CROP

私は何かを見つけようとしましたが、助けてくれました。事前に

おかげ

FATAL EXCEPTION: main 
                android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.android.camera.action.CROP dat=file:///data/data/com.android.gallery3d/files/crop-temp (has extras) } 
                 at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1628) 
                 at android.app.Instrumentation.execStartActivity(Instrumentation.java:1423) 
                 at android.app.Activity.startActivityForResult(Activity.java:3388) 
                 at android.app.Activity.startActivityForResult(Activity.java:3349) 
                 at com.android.camera.actor.PhotoActor.doAttach(PhotoActor.java:1125) 
                 at com.android.camera.actor.PhotoActor.access$500(PhotoActor.java:62) 
                 at com.android.camera.actor.PhotoActor$2.onClick(PhotoActor.java:210) 
                 at android.view.View.performClick(View.java:4209) 
                 at android.view.View$PerformClick.run(View.java:17431) 
                 at android.os.Handler.handleCallback(Handler.java:725) 
                 at android.os.Handler.dispatchMessage(Handler.java:92) 
                 at android.os.Looper.loop(Looper.java:153) 
                 at android.app.ActivityThread.main(ActivityThread.java:5297) 
                 at java.lang.reflect.Method.invokeNative(Native Method) 
                 at java.lang.reflect.Method.invoke(Method.java:511) 
                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 
                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 
                 at dalvik.system.NativeStart.main(Native Method) 

は、これは私のコードです:

@Override 
    public void onButton1Click(int ref) { 
     try { 
      currentRef = ref; 
      Intent mIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 

      Uri fileUri = FileProvider.getUriForFile(getActivity(), BuildConfig.APPLICATION_ID + ".provider", createImageFile()); 
      mIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name 
      mIntent.putExtra("crop", "true"); 
      startActivityForResult(mIntent, REQUEST_TAKE_PHOTO); 
     }catch (IOException ex) { 
      ex.printStackTrace(); 
     } 
    } 


private File createImageFile() throws IOException { 
     // Create an image file name 
     String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); 
     String imageFileName = "JPEG_" + timeStamp + "_"; 
     File storageDir = new File(Environment.getExternalStoragePublicDirectory(
       Environment.DIRECTORY_DCIM), "Camera"); 
     File image = File.createTempFile(
       imageFileName, /* prefix */ 
       ".jpg",   /* suffix */ 
       storageDir  /* directory */ 
     ); 

     // Save a file: path for use with ACTION_VIEW intents 
     mCurrentPhotoPath = "file:" + image.getAbsolutePath(); 
     return image; 
    } 
+0

アンドロイドでCROPを処理する意図はありません。 – W4R10CK

+0

あなたはもっと何か答えを説明できますか?どのように私のコードにそれを統合することができますか? –

+0

ここをクリックhttps://commonsware.com/blog/2013/01/23/no-android-does-not-have-crop-intent.html – W4R10CK

答えて

2

いいえ、Androidは

多くの開発者は、と意図にstartActivity()を呼び出している作物の意図を持っていませんアクションはcom.android.camera.action.CROPです。彼らは画像を切り抜くためにこれをやっています。

これは本当に悪い考えです。

Source here - CommonsBlog

enter image description here

関連する問題