android throw InvocationTargetException,How to modify it?

Put your problem here if it does not fit any of the other categories.

android throw InvocationTargetException,How to modify it?

Postby fonter » Wed May 26, 2010 9:46 am

Code: Select all
      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
fonter
Junior Developer
Junior Developer
 
Posts: 17
Joined: Wed Apr 28, 2010 10:45 am

Top

Re: android throw InvocationTargetException,How to modify it

Postby nicholas.hauschild » Fri May 28, 2010 11:24 pm

Your issue is clearly listed in the stack trace you provided!!!

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
nicholas.hauschild
Master Developer
Master Developer
 
Posts: 310
Joined: Fri Dec 04, 2009 4:50 am

Re: android throw InvocationTargetException,How to modify it

Postby fonter » Sat May 29, 2010 9:40 am

nicholas.hauschild wrote:Your issue is clearly listed in the stack trace you provided!!!

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


how to modify it?

this is my androidmanifest.xml

Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.iwidsets.task.manager"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:label="@string/app_name" android:name="Splash">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    <activity android:name="TaskManager"></activity>
<activity android:name=".gui.RunningAppProcessActivity"></activity>
<activity android:name=".gui.ServiceActivity"></activity>
<activity android:name=".gui.MemoryActivity"></activity>
<activity android:name=".gui.RecentActivity"></activity>
<activity android:name=".gui.RunningTaskActivity"></activity>
<activity android:name=".gui.SettingsActivity"></activity>
<activity android:name=".gui.InstalledAppsActivity"></activity>
<activity android:name=".gui.InstalledAppDetails"></activity>
</application>
    <uses-sdk android:minSdkVersion="3" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.GET_TASKS"></uses-permission>
<uses-permission android:name="android.permission.GET_PACKAGE_SIZE"></uses-permission>
<uses-permission android:name="android.permission.RESTART_PACKAGES"></uses-permission>
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
<uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT"/>

<uses-permission android:name="android.permission.CLEAR_APP_USER_DATA"></uses-permission>
<uses-permission android:name="android.permission.CLEAR_APP_CACHE"></uses-permission>
</manifest>
fonter
Junior Developer
Junior Developer
 
Posts: 17
Joined: Wed Apr 28, 2010 10:45 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 16 guests