[android-developers] Clicking a link in Browser initates a new Intent

2010-01-06 Thread Balder
I am working on an app that I want to be able to open links from eg.
an email app. I have an intent-filter that looks like this:

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 /
/intent-filter

Now, if I click a link in an email, I get the dialog where I can
choose whether to open the link with my app or with Browser. This is
all well and good, but I also get this dialog whenever I click a link
in the Browser app, or even enter a URL in the address field! I've
noticed that the Steel browser doesn't work like this; clicking a link
in Steel simply opens the link. Is there a way to circumvent this
behavior in the Browser app, yet still present my app as an option
when clicking links in email clients and the like?
-- 
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

[android-developers] Re: Clicking a link in Browser initates a new Intent

2010-01-06 Thread Balder
On Jan 6, 2:55 pm, Mark Murphy mmur...@commonsware.com wrote:
  Now, if I click a link in an email, I get the dialog where I can
  choose whether to open the link with my app or with Browser. This is
  all well and good, but I also get this dialog whenever I click a link
  in the Browser app, or even enter a URL in the address field!

 That's what you specified in the intent filter -- you claim to support
 every HTTP(S) URL everywhere regardless of MIME type, host, or anything
 else.

That is correct, yes.

 That's why the intent filter is evil.

Evil is a bit harsh, isn't it? :) After all, it's pretty much the
same filter used by Browser (with the omission of about: URIs)

  Is there a way to circumvent this
  behavior in the Browser app, yet still present my app as an option
  when clicking links in email clients and the like?

 Intent filters are agnostic to the sender of the Intent, so anything in
 the system could send an Intent that your intent filter will match. Then,
 if the sender uses Intent.createChooser(), like the Browser app does, you
 will appear as a viable option.

I guess this part is my actual problem. I can see why the email app
would invoke ResolverActivity, but why the Browser would do this for
every clicked link and every entered URL is unclear to me. As
mentioned, Steel doesn't do this. Setting Steel to the default URL
handler will therefore, in effect, render the Browser app unusable
since any click or address entry in Browser will be sent to Steel.

It seems like the answer to my question is no then?

 Furthermore, you really need to more tightly constrain that intent filter,
 so it is only going to be used for MIME types you actually will support,
 or only from certain sites, or something. Look at the data element in
 the SDK documentation:

Well, the MIME type of a HTTP(S) resource will be unknown until the
network resource is opened, won't it? For example when I click a link
in an email. Anyway, since text/html and application/xhtml+xml are
among the MIME types I'm interested in, I guess it wouldn't help me if
I did know the type beforehand; Browser would still pop up a chooser
that contained my app along with Browser itself.
-- 
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

[android-developers] Re: Clicking a link in Browser initates a new Intent

2010-01-06 Thread Balder
 This is not significantly different than on other platforms. For example,
 I have no idea how you'd tell Windows that you are the default handler for
 http:// URLs...but only if they are launched from Outlook and not from
 other apps.

Well, to use the Windows analogy, I'd be happy to open links from
Thunderbird and MSN Messenger as well, but probably not Chrome or IE.
The Android browser is different in the respect that if you tell
Windows that you are the default handler for HTTP URLs, IE will still
be able to both open a web page and follow its links without launching
the newly set default browser. In fact, having a browser ask you which
app you want to open a web page in every time you click a link seems a
bit redundant. Oh well, seems like I'll need to figure out some not-
too-nasty hack.
-- 
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

[android-developers] Re: Application disappears from recent apps list

2009-12-30 Thread Balder
On Dec 15, 4:08 pm, Balder balderm...@gmail.com wrote:
 I am writing an app that wants to be able to handle URLs. I also want
 to be able to launch it stand-alone with no arguments, so I've
 specified two intent filters:

(snip)

I'd just like to bump this one. Hopefully someone has encountered the
same problem and/or found a solution since my original post :)

-- 
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


[android-developers] Application disappears from recent apps list

2009-12-15 Thread Balder
I am writing an app that wants to be able to handle URLs. I also want
to be able to launch it stand-alone with no arguments, so I've
specified two intent filters:

intent-filter
  action android:name=android.intent.action.MAIN /
  category android:name=android.intent.category.LAUNCHER /
 /intent-filter
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 /
/intent-filter

I have also specified android:launchMode=singleTask. Now, if I
explicitly launch my application from the application list, its name
and icon can be found in the recent apps list that pops up when I
hold the home key. If I then use the email application to open a URL
in my application, my application disappears from the recent apps
list. Why does this happen, and what can I do about it? I notice that
the Browser application doesn't behave like this, and it has similar
intent filters and the same launchMode.

-- 
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