开发者

Starting InstalledAppDetails for certain application is causes force close

I am working on an application whose job it is to clear the browser history. As part of this process I send the user to the APPLICATIONS_DETAILS_SETTINGS screen for the browser so they can press the "Force Stop" button, which will close any windows which are currently open in the browser. This is the code that I am using to open up to the app details activity for the browser package.

    killBrowserIntent = new Intent();
    killBrowserIntent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS"); // I have tried "android.intentaction.VIEW" here as well.
    killBrowserIntent.setData(Uri.parse("package:com.android.browser"));
    ComponentName cn = new ComponentName("com.android.settings", "com.android.settings.applications.InstalledAppDetails");
    killBrowserIntent.setComponent(cn);

This works great on many devices. However one of the devices I am testing on this causes a force close with the following log:

09-23 08:21:26.231: INFO/ActivityManager(231): Starting: Intent { act=android.settings.APPLICATION_DETAILS_SETTINGS dat=package:com.android.browser cmp=com.android.settings/.applications.InstalledAppDetails } from pid 3497
09-23 08:04:23.833: INFO/ActivityManager(231): Start proc com.android.settings for activity com.android.settings/.applications.InstalledAppDetails: pid=3434 uid=1000 gids={1015, 3002, 3001, 3003, 2001, 1007, 3005}
09-23 08:04:23.843: WARN/InputManagerService(231): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@407e4ec0
09-23 08:04:23.873: INFO/ActivityManager(231): No longer want com.motorola.android.deviceinformationprovider (pid 3124): hidden #21
09-23 08:04:23.893: WARN/dalvikvm(3434): Refusing to reopen boot DEX '/system/framework/com.motorola.android.frameworks.jar'
09-23 08:04:23.903: WARN/dalvikvm(3434): Refusing to reopen boot DEX '/system/framework/com.motorola.android.ptt.common.jar'
09-23 08:04:24.083: WARN/dalvikvm(3434): threadid=1: thread exiting with uncaught exception (group=0x4001e560)
09-23 08:04:24.083: ERROR/AndroidRuntime(3434): FATAL EXCEPTION: main
09-23 08:04:24.083: ERROR/AndroidRuntime(3434): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.settings/com.android.settings.applications.InstalledAppDetails}: java.lang.NullPointerException
09-23 08:04:24.083: ERROR/AndroidRuntime(3434):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1702)
09-23 08:04:24.083: ERROR/AndroidRuntime(3434):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1727)
09-23 08:04:24.083: ERROR/AndroidRuntime(3434):     at android.app.ActivityThread.access$1500(ActivityThread.java:124)
09-23 08:04:24.083: ERROR/AndroidRuntime(3434):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:974)
09开发者_StackOverflow-23 08:04:24.083: ERROR/AndroidRuntime(3434):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-23 08:04:24.083: ERROR/AndroidRuntime(3434):     at android.os.Looper.loop(Looper.java:130)
09-23 08:04:24.083: ERROR/AndroidRuntime(3434):     at android.app.ActivityThread.main(ActivityThread.java:3859)
09-23 08:04:24.083: ERROR/AndroidRuntime(3434):     at java.lang.reflect.Method.invokeNative(Native Method)
09-23 08:04:24.083: ERROR/AndroidRuntime(3434):     at java.lang.reflect.Method.invoke(Method.java:507)
09-23 08:04:24.083: ERROR/AndroidRuntime(3434):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
09-23 08:04:24.083: ERROR/AndroidRuntime(3434):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:647)
09-23 08:04:24.083: ERROR/AndroidRuntime(3434):     at dalvik.system.NativeStart.main(Native Method)
09-23 08:04:24.083: ERROR/AndroidRuntime(3434): Caused by: java.lang.NullPointerException
09-23 08:04:24.083: ERROR/AndroidRuntime(3434):     at com.android.settings.applications.InstalledAppDetails.onCreate(InstalledAppDetails.java:369)
09-23 08:04:24.083: ERROR/AndroidRuntime(3434):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-23 08:04:24.083: ERROR/AndroidRuntime(3434):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1666)
09-23 08:04:24.083: ERROR/AndroidRuntime(3434):     ... 11 more
09-23 08:04:24.083: WARN/ActivityManager(231):   Force finishing activity com.android.settings/.applications.InstalledAppDetails

To dig in to it a bit further I went into settings->Manage Applications->Browser on the device manually and noticed that the Intent that is fired when I do it this way has Extras bundled into it.

This is the Intent line from the Log when this activity is launched manually:

09-23 08:23:59.470: INFO/ActivityManager(231): Starting: Intent { act=android.settings.APPLICATION_DETAILS_SETTINGS dat=package:com.android.browser cmp=com.android.settings/.applications.InstalledAppDetails (has extras) } from pid 3540

This is the Intent Line from when it is launched from my application:

09-23 08:21:26.231: INFO/ActivityManager(231): Starting: Intent { act=android.settings.APPLICATION_DETAILS_SETTINGS dat=package:com.android.browser cmp=com.android.settings/.applications.InstalledAppDetails } from pid 3497

Has anyone come across something like this before? What is the best way for me to figure out what it is that I need to Bundle up and add to the Intent in order for it to properly start on this device?

I've located the source code for the InstalledAppDetails activity, it can be found here But the line referred to in my exception is 1: outside of onCreate and 2: blank.

Is there a way that I can listen for the Intent that is fired when this activity is opened manually and unpack the extras from it so that I know what they are, and thus what I need to add to my Intent?


I'd remove the setComponent() call. It should not be needed (assuming the docs are correct), and calling setComponent() for a component that is not yours is rarely a good idea. The action string alone should route it to the appropriate activity.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜