gpt4 book ai didi

android - java.lang.SecurityException : Permission Denial: Intent in new version 4. 3

转载 作者:太空狗 更新时间:2023-10-29 14:18:30 25 4
gpt4 key购买 nike

当我从图库中选择视频时,它给出了安全类型异常。但是除了 4.3 之外,所有版本的 android 都可以使用相同的代码。我搜索了相同的答案,有人建议在 Activity 部分使用 android:exported="true" 。但我仍然遇到同样的异常。

我的代码是

@Override
public void onClick(View v) {

if(btngetvideo==v)
{
Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, 1); //<-- Here m getting exception
}

}


@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent resultData) {
super.onActivityResult(requestCode, resultCode, resultData);

Log.v(TAG + ".onActivityResult", "onActivityResult call");
try {

if ( resultData != null) {

String[] projection = { MediaStore.Video.Media.DATA };
@SuppressWarnings("deprecation")
Cursor cursor = managedQuery(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
projection, null, null, null);
int column_index_data = cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DATA);
cursor.moveToLast();
videopath= cursor.getString(column_index_data);
messageText.setText("Uploading file path :"+ videopath);
dialog = ProgressDialog.show(MainActivity.this, "", "Uploading file...", true);

new Thread(new Runnable() {
public void run() {
runOnUiThread(new Runnable() {
public void run() {
messageText.setText("uploading started.....");
}
});

uploadFile(videopath);
//uploadFile(path);

}
}).start();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}

和 list 代码:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test333"
android:versionCode="1"
android:versionName="1.0" >

< <uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_USER_DICTIONARY"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>



<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

Logcat 错误

10-04 08:21:42.549: E/AndroidRuntime(874): FATAL EXCEPTION: main
10-04 08:21:42.549: E/AndroidRuntime(874): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.PICK dat=content://media/external/video/media cmp=com.android.music/.VideoBrowserActivity } from ProcessRecord{41c469c8 874:com.example.test333/u0a10039} (pid=874, uid=10039) not exported from uid 10019
10-04 08:21:42.549:

E/AndroidRuntime(874): at android.os.Parcel.readException(Parcel.java:1431)
10-04 08:21:42.549: E/AndroidRuntime(874): at android.os.Parcel.readException(Parcel.java:1385)
10-04 08:21:42.549:

E/AndroidRuntime(874): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1947)
10-04 08:21:42.549:

E/AndroidRuntime(874): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1419)
10-04 08:21:42.549:

E/AndroidRuntime(874): at android.app.Activity.startActivityForResult(Activity.java:3390)
10-04 08:21:42.549:

E/AndroidRuntime(874): at android.app.Activity.startActivityForResult(Activity.java:3351)
10-04 08:21:42.549: E/AndroidRuntime(874): at com.example.test333.MainActivity.onClick(MainActivity.java:48)
10-04 08:21:42.549:

E/AndroidRuntime(874): at android.view.View.performClick(View.java:4240)
10-04 08:21:42.549: E/AndroidRuntime(874): at android.view.View$PerformClick.run(View.java:17721)
10-04 08:21:42.549:

E/AndroidRuntime(874): at android.os.Handler.handleCallback(Handler.java:730)
10-04 08:21:42.549:


E/AndroidRuntime(874): at android.os.Handler.dispatchMessage(Handler.java:92)
10-04 08:21:42.549:

E/AndroidRuntime(874): at android.os.Looper.loop(Looper.java:137)
10-04 08:21:42.549: E/AndroidRuntime(874): at android.app.ActivityThread.main(ActivityThread.java:5103)
10-04 08:21:42.549:

E/AndroidRuntime(874): at java.lang.reflect.Method.invokeNative(Native Method)
10-04 08:21:42.549:

E/AndroidRuntime(874): at java.lang.reflect.Method.invoke(Method.java:525)
10-04 08:21:42.549:

E/AndroidRuntime(874): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
10-04 08:21:42.549:

E/AndroidRuntime(874): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-04 08:21:42.549: E/AndroidRuntime(874): at dalvik.system.NativeStart.main(Native Method)

帮我解决一下谢谢

最佳答案

该错误表明 VideoBrowserActivity 未从 com.android.music 导出。 That is indeed the case in the source code ,所以这似乎是 Android 中的一个错误。我已经提交了 an issue关于它。

关于android - java.lang.SecurityException : Permission Denial: Intent in new version 4. 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19181432/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com