Is it possible to transmit text from the standard browser to my own app ? Are there maybe any broadcast intents that i can listen to when selecting text in the browser?
the only thing i know is, that there's an intent triggered when sharing a page, but that's not what i'm loo开发者_如何学编程king for.
Is it possible to transmit text from the standard browser to my own app ?
I have no idea what "transmit text" means.
You can set up a link that will launch one of your application's activities, if the activity advertises itself properly in the manifest. Here is a sample project that demonstrates this. The key is the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.commonsware.android.urlhandler" android:versionCode="1" android:versionName="1.0">
<supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="false"/>
<application android:label="@string/app_name" android:icon="@drawable/cw">
<activity android:name="URLHandler" android:label="@string/app_name">
<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:mimeType="application/pdf"/>
</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" android:host="www.this-so-does-not-exist.com"/>
</intent-filter>
<intent-filter>
<action android:name="com.commonsware.android.MY_ACTION"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
</application>
</manifest>
For example, the third <intent-filter>
will be triggered by a link to this non-existent site.
Are there maybe any broadcast intents that i can listen to when selecting text in the browser?
No, because that would be a privacy violation.
精彩评论