android throw InvocationTargetException,How to modify the error

Posted by fonter on Stack Overflow See other posts from Stack Overflow or by fonter
Published on 2010-05-26T08:43:42Z Indexed on 2010/05/26 8:51 UTC
Read the original article Hit count: 614

Filed under:
    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

© Stack Overflow or respective owner

Related posts about android