So I came up with what I thought was a great solution which worked
initially -

Intent resolveIntent = new Intent(Intent.ACTION_VIEW,
Uri.fromParts("http", "", null));
PackageManager pm = context.getPackageManager();
ResolveInfo ri = pm.resolveActivity(resolveIntent,
PackageManager.MATCH_DEFAULT_ONLY);
String packageName = ri.activityInfo.packageName;
String activityName = ri.activityInfo.name;
Intent webIntent = new Intent();
webIntent.setComponent(new ComponentName(packageName, activityName));
context.startActivity(webIntent);

This worked!  Yea.  But then I thought what if there was ANOTHER
activity on the system that services http data?  Which activity would
be selected?  So I created one to try it out.  My dummy activity has
this intent filter -

            <intent-filter android:label="Dummy HTTP Activity">
                <action android:name="android.intent.action.VIEW" />
                <category
android:name="android.intent.category.DEFAULT" />
                <category
android:name="android.intent.category.ALTERNATIVE" />
                <category
android:name="android.intent.category.SELECTED_ALTERNATIVE" />
                <data android:scheme="http" />
            </intent-filter>

I tried it without the ALTERNATIVE and SELECTED_ALTERNATIVE categories
also.  Either way I now get an intent for
com.android.internal.app.ResolverActivity and a chooser dialog that
says "No application can perform this action".  Darn.  There are TWO
apps that can perform the action.  Why does it say there are none?

Any tips on what I should be doing differently here?


On Nov 19, 7:24 pm, Brad Gies <rbg...@gmail.com> wrote:
> Do you really need to do it with an intent.... Can't you just put a
> blank page in your app, and have it load that, or put a blank page on
> your website? Or am I missing something in what you are asking for?
>
> Sincerely,
>
> Brad Gies
> -----------------------------------------------------------------------
> Bistro Bot - Bistro Blurbhttp://bgies.com           
> http://nocrappyapps.comhttp://bistroblurb.com     
> http://forcethetruth.comhttp://ihottonight.com
> -----------------------------------------------------------------------
> Everything in moderation, including abstinence (paraphrased)
>
> Every person is born with a brain... Those who use it well are the successful 
> happy ones - Brad Gies
>
> Adversity can make or break you... It's your choice... Choose wisely - Brad 
> Gies
>
> Never doubt that a small group of thoughtful, committed people can
> change the world. Indeed. It is the only thing that ever has - Margaret Mead
>
> On 19/11/2010 5:03 PM, jotobjects wrote:
>
> > Thanks for that idea - yeah not exactly what I want but its another
> > alternative.
>
> > URL "about:blank" brings up the browser with "about:blank" in the
> > input window
>
> > Scheme "http" with no URL brings up Google web search page with http:
> > in the input window.
>
> > Both of them look a little weird...
>
> > I don't think my idea of a query for "http" type and CATEGORY_LAUNCHER
> > will work either because the broswer launch intent filter does not
> > have http as a type.
>
> > So maybe there is no good way to do it. Is there anything else to try?
>
> > On Nov 19, 3:14 pm, Stephen Jungels<sjung...@gmail.com>  wrote:
> >> Have you tried using a standard intent to open the browser with the
> >> URL "about:blank" ?
>
> >> Maybe not exactly what you want, but simple and likely to work everywhere.
>
> >> On Fri, Nov 19, 2010 at 5:51 PM, jotobjects<jotobje...@gmail.com>  wrote:
> >>> Thanks -
> >>> I don't have a URL to launch and I don't want to land on the google
> >>> web search page.  The behavior I want is what happens when the user
> >>> launches the browser from the Home screen.
> >>> So maybe I should doing a PackageManager.queryIntentActivityOptions
> >>> for an Intent with CATEGORY_LAUNCHER and URI scheme "http".  and then
> >>> use the ResolveInfo to start the Activity.  Does that sound right?
> >>>                 String packageName = resolveInfo.activityInfo.packageName;
> >>>                 String activityName = resolveInfo.activityInfo.name;
> >>>                 Intent intent = new Intent();
> >>>                 intent.setComponent( new ComponentName( packageName,
> >>> activityName ) );
> >>> There are a couple of more followup questions inline below -
> >>> On Nov 18, 5:46 pm, Dianne Hackborn<hack...@android.com>  wrote:
> >>>> That Intent is okay, though there is no need for BROWSABLE.  (As per the
> >>>> documentation, BROWSABLE means that the Intent came from an untrusted 
> >>>> source
> >>>> so you want to restrict who will handle it to those that say they will
> >>>> protect themselves from such things.)
> >>> That surprises me because I interpreted the javdoc for Intent to say
> >>> that if you include a Category you must include ALL the categories
> >>> listed for that Intent. So if BROWSABLE is a category you would have
> >>> to include it - is that right?
> >>>> I'm not sure what you mean by "empty URI" -- it says "empty string", 
> >>>> which
> >>>> would just be a Uri created from an empty string.
> >>> The referenced documentation about WEB_SEARCH caused me to try this
> >>> intent -
> >>> new Intent(Intent.ACTION_WEB_SEARCH, Uri.parse(""));
> >>> but that results in this error -
> >>> android.content.ActivityNotFoundException: No Activity found to handle
> >>> Intent { act=android.intent.action.WEB_SEARCH dat= }
> >>> So I'm not sure what the documentation means here.  What should I be
> >>> doing?
> >>>> On Thu, Nov 18, 2010 at 5:05 PM, jotobjects<jotobje...@gmail.com>  wrote:
> >>>>> Thanks - I was afraid of that (although it is not quite blind luck).
> >>>>> The user's home page would be an obvious target, but there doesn't
> >>>>> seem to be a non blind luck way to find the home web page.  The
> >>>>> browser seems to bring up the last page visited which is OK since that
> >>>>> will be customary behavior for the user.
> >>>>> I also tried this, which works but lands the user on thewww.google.com
> >>>>> web page with  "http" in the input window.  Is this a valid Intent?
> >>>>> Intent webIntent = new Intent(Intent.ACTION_VIEW,Uri.fromParts("http",
> >>>>> "", null));
> >>>>> webIntent.addCategory(Intent.CATEGORY_DEFAULT);
> >>>>> webIntent.addCategory(Intent.CATEGORY_BROWSABLE);
> >>>>> Also I do not understand this documentation for how to bring up the
> >>>>> web browser  -
> >>>>>          http://developer.android.com/guide/appendix/g-app-intents.html
> >>>>> The WEB_SEARCH action mentioned there with an "empty" URI sounds like
> >>>>> what I want, but I can't figure out how to create an "empty URI" that
> >>>>> works.
> >>>>> On Nov 18, 2:52 pm, Dianne Hackborn<hack...@android.com>  wrote:
> >>>>>> That is a bogus Intent; it is just blind luck that it happens to only 
> >>>>>> run
> >>>>>> into the browser as something that happens to match it, and you can't
> >>>>> count
> >>>>>> on that doing what you want anywhere else.
> >>>>>> I don't believe there is a generic action to start "the browser;" you 
> >>>>>> are
> >>>>>> supposed to start it by asking it to view a URI.
> >>>>>> On Thu, Nov 18, 2010 at 2:39 PM, jotobjects<jotobje...@gmail.com>
> >>>>> wrote:
> >>>>>>> I want to invoke the internet browser app without giving it a URL to
> >>>>>>> open.  I have tried a couple of things.  What seems to work is this -
> >>>>>>>    Intent webIntent = new Intent(Intent.ACTION_MAIN);
> >>>>>>>    webIntent.addCategory(Intent.CATEGORY_LAUNCHER);
> >>>>>>>    webIntent.addCategory(Intent.CATEGORY_DEFAULT);
> >>>>>>>    webIntent.addCategory(Intent.CATEGORY_BROWSABLE);
> >>>>>>>    context.startActivity(webIntent);
> >>>>>>> Is there another or better Intent to use?  Is it good practice to use
> >>>>>>> the Launcher Intent for an app in this way?
> >>>>>>> --
> >>>>>>> You received this message because you are subscribed to the Google
> >>>>>>> Groups "Android Developers" group.
> >>>>>>> To post to this group, send email to
> >>>>> android-developers@googlegroups.com
> >>>>>>> To unsubscribe from this group, send email to
> >>>>>>> android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> >>>>> <android-developers%2bunsubscr...@googlegroups.com<android-developers%252bunsubscr...@googlegroups.com>
> >>>>>>> For more options, visit this group at
> >>>>>>>http://groups.google.com/group/android-developers?hl=en
> >>>>>> --
> >>>>>> Dianne Hackborn
> >>>>>> Android framework engineer
> >>>>>> hack...@android.com
> >>>>>> Note: please don't send private questions to me, as I don't have time 
> >>>>>> to
> >>>>>> provide private support, and so won't reply to such e-mails.  All such
> >>>>>> questions should be posted on public forums, where I and others can see
> >>>>> and
> >>>>>> answer them.
> >>>>> --
> >>>>> You received this message because you are subscribed to the Google
> >>>>> Groups "Android Developers" group.
> >>>>> To post to this group, send email to android-developers@googlegroups.com
> >>>>> To unsubscribe from this group, send email to
> >>>>> android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> >>>>> For more options, visit this group at
> >>>>>http://groups.google.com/group/android-developers?hl=en
> >>>> --
> >>>> Dianne Hackborn
> >>>> Android framework engineer
> >>>> hack...@android.com
> >>>> Note: please don't send private questions to me, as I don't have time to
> >>>> provide private support, and so won't reply to such e-mails.  All such
> >>>> questions should be posted on public forums, where I and others can see 
> >>>> and
> >>>> answer them.
> >>> --
> >>> You received this message because you are subscribed to the Google
> >>> Groups "Android Developers" group.
> >>> To post to this group, send email to android-developers@googlegroups.com
> >>> To unsubscribe from this group, send email to
> >>> android-developers+unsubscr...@googlegroups.com
> >>> For more options, visit this group at
> >>>http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to