Java – let Android applications listen to shared links
•
Java
When a user shares a URL from another application (such as a browser), I want my Android application to appear as an option How do I register my app? How do I react to link shares?
Thank you.
Edit:
I tried to use this intentfilter without success:
<intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> </intent-filter>
Any ideas?
Solution
At a minimum, you need to:
<activity android:name=".ShareActivity"> <intent-filter android:label="Share with my app"> <action android:name="android.intent.action.SEND" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity>
In your list, it will at least appear in the "share" list
The most important part you lack is:
<action android:name="android.intent.action.SEND" />
In order for it to actually do something, you need an activity
This may also help: @ L_ 502_ 1@
Additional information:
<activity android:name=".ShareActivity"> <intent-filter android:label="Share with my app"> <action android:name="android.intent.action.SEND" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/plain" /> </intent-filter> </activity>
Then < data Android: mimeType will limit the content of your response if you want to limit the response of your application
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码