App Chooser not being shown when google browser is the default

Last Updated:

  1. James McMurray

    James McMurray Member This Topic's Starter

    May 5, 2009
    Likes Received:
    I've seen a few other similar threads, but none that both matched my problem and had answers, so sorry if this retreads familiar ground.

    I've got a browser and I'm trying to catch the same intents as the google browser. I've even gone so far as to copy and paste them directly from Froyo's browser. They are listed down below for reference. However, when I try to send an intent to create the chooser so the user can select my browser as the default it does not always appear. Here is the code for creating the intent:

    Code (Text):
    1. Intent anIntent = new Intent("android.intent.action.VIEW",
    2.     "");
    3. anIntent.addCategory(Intent.CATEGORY_BROWSABLE);
    4. startActivity(anIntent);
    and the logcat output:

    Code (Text):
    1. 08-26 14:53:25.698: INFO/ActivityManager(85): Starting activity: Intent {
    2. act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE]
    3. dat= }
    For some reason the intent is automatically resolving to Google's browser unless one of the following is true:

    1) I've cleared the defaults from the google browser via application settings,
    2) I've installed a third browser, or even just a HelloWorld app with the intent-filters listed below, or
    3) I'm running on a platform earlier than 2.2

    What is really confusing is #2. It doesn't matter what that third app is. I've used a default hello world with just the first intent-filter and that's enough to trigger something behind the scenes that tells Google it's no longer the only default browser. However, it's not enough in my own app, and the only differences in the two manifests are that mine has a sharedUserId, a couple of extra activities (none of which have intent-filters) and permissions (none of which have anything to do with browsing, in fact HelloWorld doesn't have any permissions at all).

    The program flow is: user opens browser, it sees that it's not fully installed and opens another activity, that activity does some stuff (none of which deals with intents) and then checks to see if my browser is the default, if not it fires off the aforementioned intent to create the chooser so the user can set the default.

    When I reverse the process (install my app first, then HelloWorld) and have a button in HelloWorld that calls startActivity, the same thing happens: HelloWorld cannot show the chooser unless I've already installed a third app.

    Is there a change in froyo that would cause an application to not be able to use startActivity with a generic intent that matches to its own package? Or some other change to the way activities are resolved or installed that broke the way preferred activities are defined? I know that the PackageManager preferred activity functions have changed, but I'm not using them at all.

    ----- the intent-filters -----
    Code (Text):
    1. <intent-filter>
    2.         <action android:name="android.intent.action.VIEW" />
    3.         <category android:name="android.intent.category.DEFAULT" />
    4.         <category android:name="android.intent.category.BROWSABLE" />
    5.         <data android:scheme="http" />
    6.         <data android:scheme="https" />
    7.         <data android:scheme="about" />
    8.         <data android:scheme="javascript" />
    9. </intent-filter>
    10. <!--  For these schemes where any of these particular MIME types
    11.           have been supplied, we are a good candidate. -->
    12. <intent-filter>
    13.         <action android:name="android.intent.action.VIEW" />
    14.         <category android:name="android.intent.category.BROWSABLE" />
    15.         <category android:name="android.intent.category.DEFAULT" />
    16.         <data android:scheme="http" />
    17.         <data android:scheme="https" />
    18.         <data android:scheme="inline" />
    19.         <data android:mimeType="text/html"/>
    20.         <data android:mimeType="text/plain"/>
    21.         <data android:mimeType="application/xhtml+xml"/>
    22.         <data android:mimeType="application/vnd.wap.xhtml+xml"/>
    23. </intent-filter>
    24. <!-- We are also the main entry point of the browser. -->
    25. <intent-filter>
    26.         <action android:name="android.intent.action.MAIN" />
    27.         <category android:name="android.intent.category.DEFAULT" />
    28.         <category android:name="android.intent.category.LAUNCHER" />
    29.         <category android:name="android.intent.category.BROWSABLE" />
    30. </intent-filter>

  2. James McMurray

    James McMurray Member This Topic's Starter

    May 5, 2009
    Likes Received:
    followup: It seems that the OS is remembering preference orders in between installations. So if they ever chose the google browser over mine, the OS will always choose the google browser over mine until either:

    1) the google browser's defaults are cleared, or
    2) another application is installed that listens to those intents, resetting the need for a chooser

Share This Page