On Thu, Jun 30, 2011 at 12:59 AM, Android Beta <[email protected]> wrote:
> What I want to do is basically have an application run in the
> background.
Why?
> So what the user would basically do is open the
> application and then switch to a browser. After the User has opened up
> the browser he would go on to clicking menu - more - share page and
> would find the application name on the "To:" textfield.
"Share page" brings up a chooser dialog, showing available activities
that handle ACTION_SEND for text/plain. There is no "To:" "textfield"
on this dialog.
> They would
> then press send and then the application would redeem focus again and
> the application would now have the url and it would proceed to do
> whatever is needed.
That is not how this works.
> My Question is how do I add a listener to the application and how do i
> add the application name so you are able to see it into the "To:" so
> when you press send the application would recieve the url and would
> would do whatever the application needs.
That is not how this works.
Add the following <intent-filter> to an <activity> in your manifest:
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.SEND" />
<data android:mimeType="text/plain" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Then, your activity will appear in the chooser dialog for "Share
page". If the user clicks on the entry for your activity, your
activity will be created, and you can retrieve the URL of the page via
getIntent().getStringExtra(Intent.EXTRA_TEXT).
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy
_The Busy Coder's Guide to *Advanced* Android Development_ Version
1.9.9 Available!
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en