gpt4 book ai didi

android throw InvocationTargetException,如何修改错误

转载 作者:行者123 更新时间:2023-11-30 04:52:19 25 4
gpt4 key购买 nike

    ActivityManager am = (ActivityManager)this.getSystemService(this.ACTIVITY_SERVICE);

try {
clearMethod = am.getClass()
.getMethod("clearApplicationUserData", String.class,
IPackageDataObserver.class);
} catch (Exception e) {
Log.e("Error", "Android Error",e);
clearMethod = null;
}

if(clearMethod!=null){
try {
clearMethod.invoke(am,"com.android.browser",new ClearUserDataObserver());
} catch (Exception e) {
Log.e("Error", "Android Exception",e);
}
}



Exception

05-26 08:34:13.056: ERROR/Error(739): java.lang.reflect.InvocationTargetException
05-26 08:34:13.056: ERROR/Error(739): at android.app.ActivityManager.clearApplicationUserData(ActivityManager.java:475)
05-26 08:34:13.056: ERROR/Error(739): at java.lang.reflect.Method.invokeNative(Native Method)
05-26 08:34:13.056: ERROR/Error(739): at java.lang.reflect.Method.invoke(Method.java:521)
05-26 08:34:13.056: ERROR/Error(739): at com.iwidsets.clear.manager.AndClear.onCreate(AndClear.java:34)
05-26 08:34:13.056: ERROR/Error(739): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
05-26 08:34:13.056: ERROR/Error(739): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
05-26 08:34:13.056: ERROR/Error(739): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
05-26 08:34:13.056: ERROR/Error(739): at android.app.ActivityThread.access$2100(ActivityThread.java:116)
05-26 08:34:13.056: ERROR/Error(739): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
05-26 08:34:13.056: ERROR/Error(739): at android.os.Handler.dispatchMessage(Handler.java:99)
05-26 08:34:13.056: ERROR/Error(739): at android.os.Looper.loop(Looper.java:123)
05-26 08:34:13.056: ERROR/Error(739): at android.app.ActivityThread.main(ActivityThread.java:4203)
05-26 08:34:13.056: ERROR/Error(739): at java.lang.reflect.Method.invokeNative(Native Method)
05-26 08:34:13.056: ERROR/Error(739): at java.lang.reflect.Method.invoke(Method.java:521)
05-26 08:34:13.056: ERROR/Error(739): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
05-26 08:34:13.056: ERROR/Error(739): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
05-26 08:34:13.056: ERROR/Error(739): at dalvik.system.NativeStart.main(Native Method)
05-26 08:34:13.056: ERROR/Error(739): Caused by: java.lang.SecurityException: 739 does not have permission:android.permission.CLEAR_APP_USER_DATA to clear datafor process:com.android.browser
05-26 08:34:13.056: ERROR/Error(739): at android.os.Parcel.readException(Parcel.java:1218)
05-26 08:34:13.056: ERROR/Error(739): at android.os.Parcel.readException(Parcel.java:1206)
05-26 08:34:13.056: ERROR/Error(739): at android.app.ActivityManagerProxy.clearApplicationUserData(ActivityManagerNative.java:2016)
05-26 08:34:13.056: ERROR/Error(739): ... 17 more

这是我的androidManifest.xml文件

   <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.iwidsets.clear.manager"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".AndClear"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>
<uses-sdk android:minSdkVersion="4" />


<uses-permission android:name="android.permission.CLEAR_APP_USER_DATA"></uses-permission>
<uses-permission android:name="android.permission.CLEAR_APP_CACHE"></uses-permission>
</manifest>

最佳答案

您无法修改错误。

您缺少权限,请检查您的 logcat 输出中的这一行:

.SecurityException: 739 does not have permission:android.permission.CLEAR_APP_USER_DATA to clear datafor process:com.android.browser

关于android throw InvocationTargetException,如何修改错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2911353/

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