views:

564

answers:

2

I am creating an application that checks the installation of a package and then launches the market-place with its id.

When I try to launch market place with id of an application say com.mybrowser.android by throwing an intent android.intent.action.VIEW with url: market://details?id=com.mybrowser.android, the market place application does launches but crashes after launch.

Note: the application com.mybrowser.android doesn't exists in the market-place.

MyApplication is my application.

$ adb logcat

I/ActivityManager( 1030): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=myapp.testapp/.MyApplication }
I/ActivityManager( 1030): Start proc myapp.testapp for activity myapp.testapp/.MyApplication: pid=3858 uid=10047 gids={1015, 3003}
I/MyApplication( 3858): [ Activity CREATED ]
I/MyApplication( 3858): [ Activity STARTED ]
I/MyApplication( 3858): onResume
D/dalvikvm( 1109): GC freed 6571 objects / 423480 bytes in 73ms
I/MyApplication( 3858): Pressed OK button
I/MyApplication( 3858): Broadcasting Intent: android.intent.action.VIEW, data: market://details?id=com.mybrowser.android
I/ActivityManager( 1030): Starting activity: Intent { act=android.intent.action.VIEW dat=market://details?id=com.mybrowser.android flg=0x10000000 cmp=com.android.ven
ding/.AssetInfoActivity }
I/MyApplication( 3858): onPause
I/ActivityManager( 1030): Start proc com.android.vending for activity com.android.vending/.AssetInfoActivity: pid=3865 uid=10023 gids={3003}
I/ActivityThread( 3865): Publishing provider com.android.vending.SuggestionsProvider: com.android.vending.SuggestionsProvider
D/dalvikvm( 1030): GREF has increased to 701
I/vending ( 3865): com.android.vending.api.RadioHttpClient$1.handleMessage(): Handle DATA_STATE_CHANGED event: NetworkInfo: type: WIFI[], state: CONNECTED/CO
NNECTED, reason: (unspecified), extra: (none), roaming: false, failover: false, isAvailable: true
I/ActivityManager( 1030): Displayed activity com.android.vending/.AssetInfoActivity: 609 ms (total 7678 ms)
D/dalvikvm( 1030): GC freed 10458 objects / 676440 bytes in 128ms
I/MyApplication( 3858): [ Activity STOPPED ]
D/dalvikvm( 3865): GC freed 3538 objects / 254008 bytes in 84ms
W/dalvikvm( 3865): threadid=19: thread exiting with uncaught exception (group=0x4001b180)
E/AndroidRuntime( 3865): Uncaught handler: thread AsyncTask #1 exiting due to uncaught exception
E/AndroidRuntime( 3865): java.lang.RuntimeException: An error occured while executing doInBackground()
E/AndroidRuntime( 3865):        at android.os.AsyncTask$3.done(AsyncTask.java:200)
E/AndroidRuntime( 3865):        at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
E/AndroidRuntime( 3865):        at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
E/AndroidRuntime( 3865):        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
E/AndroidRuntime( 3865):        at java.util.concurrent.FutureTask.run(FutureTask.java:137)
E/AndroidRuntime( 3865):        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
E/AndroidRuntime( 3865):        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
E/AndroidRuntime( 3865):        at java.lang.Thread.run(Thread.java:1096)
E/AndroidRuntime( 3865): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 3865):        at com.android.vending.AssetItemAdapter$ReloadLocalAssetInformationTask.doInBackground(AssetItemAdapter.java:845)
E/AndroidRuntime( 3865):        at com.android.vending.AssetItemAdapter$ReloadLocalAssetInformationTask.doInBackground(AssetItemAdapter.java:831)
E/AndroidRuntime( 3865):        at android.os.AsyncTask$2.call(AsyncTask.java:185)
E/AndroidRuntime( 3865):        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
E/AndroidRuntime( 3865):        ... 4 more
I/Process ( 1030): Sending signal. PID: 3865 SIG: 3
I/dalvikvm( 3865): threadid=7: reacting to signal 3
I/dalvikvm( 3865): Wrote stack trace to '/data/anr/traces.txt'
I/DumpStateReceiver( 1030): Added state dump to 1 crashes
D/AndroidRuntime( 3865): Shutting down VM
W/dalvikvm( 3865): threadid=3: thread exiting with uncaught exception (group=0x4001b180)
E/AndroidRuntime( 3865): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 3865): java.lang.NullPointerException
E/AndroidRuntime( 3865):        at com.android.vending.controller.AssetInfoActivityController.getIdDeferToLocal(AssetInfoActivityController.java:637)
E/AndroidRuntime( 3865):        at com.android.vending.AssetInfoActivity.displayAssetInfo(AssetInfoActivity.java:556)
E/AndroidRuntime( 3865):        at com.android.vending.AssetInfoActivity.access$800(AssetInfoActivity.java:74)
E/AndroidRuntime( 3865):        at com.android.vending.AssetInfoActivity$LoadAssetInfoAction$1.run(AssetInfoActivity.java:917)
E/AndroidRuntime( 3865):        at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime( 3865):        at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 3865):        at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 3865):        at android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime( 3865):        at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3865):        at java.lang.reflect.Method.invoke(Method.java:521)   
E/AndroidRuntime( 3865):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 3865):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime( 3865):        at dalvik.system.NativeStart.main(Native Method)
I/Process ( 1030): Sending signal. PID: 3865 SIG: 3
W/ActivityManager( 1030): Process com.android.vending has crashed too many times: killing!
D/ActivityManager( 1030):   Force finishing activity com.android.vending/.AssetInfoActivity
I/dalvikvm( 3865): threadid=7: reacting to signal 3
D/ActivityManager( 1030): Force removing process ProcessRecord{44e48548 3865:com.android.vending/10023} (com.android.vending/10023)

However, when I try to launch the market place for a package that exists in the market place say com.opera.mini.android, everything works. Log for this case:

D/dalvikvm(  966): GC freed 2781 objects / 195056 bytes in 99ms
I/MyApplication( 1165): Pressed OK button
I/MyApplication( 1165): Broadcasting Intent: android.intent.action.VIEW, data: market://details?id=com.opera.mini.android
I/ActivityManager(   78): Starting activity: Intent { act=android.intent.action.VIEW dat=market://details?id=com.opera.mini.android flg=0x10000000 cmp=com.android.vending/.AssetInfoActivity }
I/AndroidRuntime( 1165): AndroidRuntime onExit calling exit(0)
I/WindowManager(   78): WIN DEATH: Window{44c72308 myapp.testapp/myapp.testapp.MyApplication paused=true}
I/ActivityManager(   78): Process myapp.testapp (pid 1165) has died.
I/WindowManager(   78): WIN DEATH: Window{44c72958 myapp.testapp/myapp.testapp.MyApplication paused=false}
D/dalvikvm(   78): GC freed 31778 objects / 1796368 bytes in 142ms
I/ActivityManager(   78): Displayed activity com.android.vending/.AssetInfoActivity: 214 ms (total 22866 ms)
W/KeyCharacterMap(  978): No keyboard for id 65540
W/KeyCharacterMap(  978): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
V/RenderScript_jni(  966): surfaceCreated
V/RenderScript_jni(  966): surfaceChanged
V/RenderScript(  966): setSurface 480 762 0x573430
D/ViewFlipper(  966): updateRunning() mVisible=true, mStarted=true, mUserPresent=true, mRunning=true
D/dalvikvm(  978): GC freed 10065 objects / 624440 bytes in 95ms

Any ideas?

A: 

instead of launching with the exact ID, you can try doing it by searching by the package.

Intent intent = new Intent( Intent.ACTION_VIEW,
Uri.parse("market://search?q=pname:com.package.package2.package3"));
startActivity(intent);

Daniel Benedykt
Am working an application that launches the market place for another application.Ideally, that application would be in market before this app would be released.While testing my application I found this issue.The market-place shouldn't crash under any conditions. Probably, it could show an error to the user.Or am doing anything wrong?Thanks!
Gaurav
As you can see, market app can crash when you send wrong info. There are lots of ways to make other google apps crash by sending intents with wrong info. I dont think you are doing something wrong, but its better to use search in case it doesn't exist at the time of calling.
Daniel Benedykt
A: 

I am having similar problem when trying to open a detail page in Market app using "market://details?id=pname:org.rabold.android.puzzleblox" URL from an application.

I can create a shortcut using AnyCut like this:

action: android.intent.action.VIEW data: market://details?id=pname:org.rabold.android.puzzleblox type:

then it works fine.

However, if I create an Android application with a button to launch Market with the same Uri as above, then I get an error in Market app like this: "Attention: A server error has occurred. Retry, or cancel and return to the previous screen."

The code of my button's listener looks like this:

okButton = (Button) findViewById(R.id.okButton);
okButton.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        Intent intent = new Intent(Intent.ACTION_VIEW, 
            Uri.parse("market://details?id=pname:org.rabold.android.puzzleblox"));
            //Uri.parse("market://search?q=pname:org.rabold.android.puzzleblox"));
            startActivity(intent);
   }
});

Note in the above code, if I use 'search' instead of 'details' then it works. I'd like to use 'details' instead of 'search' because I know that my app will be available on Market when it's done. Thanks.

TPham