2013-03-22 75 views
0

我已经发布了一个应用程序,让用户可以拍摄照片在它。我这样做是为了拍摄照片:ActivityNotFoundException,图像捕获?

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,和它的作品fine.But当我在Android4.0.3运行我的应用程序,它崩溃:

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

我怎么能SOLV这个问题?

回答

4

几件事情可以发生

  1. 可能没有任何相机设备
  2. 没有在设备

没有你的情况符合上述任何一项没有SD卡?

+0

你的情况是怎样的? – stinepike 2013-03-26 06:10:53

3

检查是否您的

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

将以下内容添加到清单。

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

将阻止应用程序从谷歌播放下载。 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!"); 
    } 


} 
}