【问题标题】:ActivityNotFoundException, image capturing?ActivityNotFoundException,图像捕获?
【发布时间】:2013-03-22 07:57:26
【问题描述】:

我发布了一个应用程序,用户可以在其中拍照。我这样做是为了拍照:

File file = new File( _path );
Uri outputFileUri = Uri.fromFile( file );   
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
intent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri );      
startActivityForResult( intent, 0 );

我还将此权限添加到清单中:

<uses-permission android:name="android.permission.CAMERA" />

我在Android2.3.5Android3.0 上测试了我的应用程序,它运行良好。但是当我在Android4.0.3 上运行我的应用程序时,它崩溃了:

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.media.action.IMAGE_CAPTURE (has extras) }

我该如何解决这个问题?

【问题讨论】:

    标签: android android-camera activitynotfoundexception


    【解决方案1】:

    可能会发生一些事情

    1. 设备中可能没有任何摄像头
    2. 设备中没有 sd 卡

    您的案例是否符合上述任何条件?

    【讨论】:

      【解决方案2】:

      检查你的

      1.平板电脑有摄像头(如果您使用平板电脑)。 2.手机有摄像头 3.没有安装SD卡。

      将以下内容添加到清单中。

         <uses-feature android:name="android.hardware.camera" />
      

      将阻止从 google play 下载应用程序。 http://developer.android.com/google/play/filters.html

      同时检查http://developer.android.com/guide/topics/manifest/uses-feature-element.html

      检查您的设备是否有摄像头。

      public class MainActivity extends Activity {
      
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          //setContentView(R.layout.main);
      
          Context context = this;
          PackageManager packageManager = context.getPackageManager();
      
          // if device support camera?
          if (packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
              //yes
              Log.i("camera", "This device has camera!");
          }else{
              //no
              Log.i("camera", "This device has no camera!");
          }
      
      
      }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-01-25
        • 2015-06-19
        • 1970-01-01
        • 2014-11-01
        • 1970-01-01
        • 2015-12-21
        • 2012-01-06
        • 2014-04-03
        相关资源
        最近更新 更多