Android Forums

Go Back   Android Forums > Android Coders > Android Development, Answers, Tutorials, and Code Snippets
Connect with Facebook

Click Here To Register!
Reply
 
LinkBack Thread Tools Display Modes
Old 08-27-2010, 09:46 AM   #1
New Member
 
Join Date: May 2009
Posts: 8
Friends: 0
View James McMurray's Profile   View James McMurray's Photo Album   View James McMurray's Blog   View Social Groups
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:
Intent anIntent = new Intent("android.intent.action.VIEW", 
	"http://www.google.com");
anIntent.addCategory(Intent.CATEGORY_BROWSABLE);
startActivity(anIntent);
and the logcat output:

Code:
08-26 14:53:25.698: INFO/ActivityManager(85): Starting activity: Intent { 
act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] 
dat=http://www.google.com cmp=com.android.browser/.BrowserActivity }
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:
<intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="http" />
        <data android:scheme="https" />
        <data android:scheme="about" />
        <data android:scheme="javascript" />
</intent-filter>
<!--  For these schemes where any of these particular MIME types
          have been supplied, we are a good candidate. -->
<intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.BROWSABLE" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:scheme="http" />
        <data android:scheme="https" />
        <data android:scheme="inline" />
        <data android:mimeType="text/html"/>
        <data android:mimeType="text/plain"/>
        <data android:mimeType="application/xhtml+xml"/>
        <data android:mimeType="application/vnd.wap.xhtml+xml"/>
</intent-filter>
<!-- We are also the main entry point of the browser. -->
<intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.LAUNCHER" />
        <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
James McMurray is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Reply With Quote
Reply

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Default browser not working properly Stomil Magic 0 04-24-2010 05:48 AM
[SOLUTION FOUND!] animated gifs in browser-webview- offical google dev fix generic.imitation Android Development, Answers, Tutorials, and Code Snippets 0 03-29-2010 04:55 PM
Any google image browser application? (HTC Hero) koldtoft Android Games And Applications 0 09-03-2009 04:38 AM


Unlocked G1 Phones | Buy T-Mobile G1 | Google Phone

All times are GMT -6. The time now is 11:45 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.
Copyright (c) 2008 TalkAndroid.com. All rights reserved.