I want that when I click on the option in the browser, I’m sharing it with the list of possible applications. When choosing my application, I want it to receive a link from this site. I do not know how to implement it and what kind of intention filters are needed for this. Please tell me how to do this, or the technology needed for this.
1 answer
To begin, add to your manifest intent-filter for the Activity where you will receive an Intent.
<activity android:name=".MainActivity" android:label="@string/app_name" android:theme="@style/AppTheme.MyTheme" > <intent-filter> <action android:name="android.intent.action.SEND"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/> <data android:mimeType="text/plain"/> </intent-filter> </activity> Your app should now be on the share list.
Further in Activity we accept Intent:
String url = getIntent().getStringExtra(Intent.EXTRA_TEXT); Log.d("MyActivity", "onCreate: " + url); |