Intent.createChooser得到了java.lang.SecurityException

时间:2014-03-05 08:03:19

标签: java android

我遇到了一个问题。 这是我的代码

Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI);

intent = Intent.createChooser(intent, "Pick");

startActivity(intent, 0);

但我得到了

java.lang.RuntimeException: Unable to start activity ComponentInfo{android/com.android.internal.app.ChooserActivity}: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.PICK dat=content://media/external/video/media flg=0x3000000 cmp=com.android.music/.VideoBrowserActivity }

在许多Android设备上。

我尝试通过

捕获此异常
try{
startActivity(intent, 0);
}catch(Exception ex){
//nothing to do
}

但它不起作用。

如何捕获此异常以使我的应用程序不崩溃?

1 个答案:

答案 0 :(得分:1)

我也遇到过类似的问题,我担心它无法解决。所以......也许您可以发送报告或尝试其他环境,例如iOS。