找不到用于处理Intent com.android.camera.action.CROP的活动 [英] No Activity found to handle Intent com.android.camera.action.CROP

查看:292
本文介绍了找不到用于处理Intent com.android.camera.action.CROP的活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我的应用程序中制作图片.我可以启动相机并拍照,但是完成拍照后,我的应用程序崩溃了.我在屏幕上看到我的Galery已停止,这是我的日志中的错误:

I'm trying to do a picture from my application. I can launch the camera and do the picture, but when has finish to do the picture my app crash. I can see in my screen that my Galery is stopped and this is the error in my log:

我试图找到一些东西,但是对我有帮助.

I've tried to find something but any help me.

预先感谢

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;
    }

推荐答案

否,Android 没有有作物意图

No, Android Does Not Have a Crop Intent

许多开发人员正在使用com.android.camera.action.CROP动作在Intent上调用startActivity().他们正在这样做以裁剪图像.

Many developers are calling startActivity() on an Intent with an action of com.android.camera.action.CROP. They are doing this to crop an image.

这是一个非常糟糕的主意.

This is a really bad idea.

在此处来源-CommonsBlog

这篇关于找不到用于处理Intent com.android.camera.action.CROP的活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆