<action android:name="android.intent.action.SEND" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/plain" />
this is in my manifest file
this will make my app appear on the share list of all apps but I want my app to appear in the share list of another specific app and I don't own the other app
Add this code in the activity you want opened first when sharing a content from outside the app, call this method in onCreate()
private void onSharedIntent() { Intent receiverdIntent = getIntent(); String receivedAction = receiverdIntent.getAction(); String receivedType = receiverdIntent.getType(); if (receivedAction.equals(Intent.ACTION_SEND)) { // check mime type if (receivedType.startsWith("text/")) { String receivedText = receiverdIntent .getStringExtra(Intent.EXTRA_TEXT); if (receivedText != null) { //do your stuff } } else if (receivedType.startsWith("image/")) { Uri receiveUri = (Uri) receiverdIntent .getParcelableExtra(Intent.EXTRA_STREAM); if (receiveUri != null) { //do your stuff fileUri = receiveUri;// save to your own Uri object Log.e(TAG,receiveUri.toString()); } } } else if (receivedAction.equals(Intent.ACTION_MAIN)) { Log.e(TAG, "onSharedIntent: nothing shared" ); } }
Add this in Manifest,
<activity android:name="your-package-name.YourActivity"> <intent-filter> <action android:name="android.intent.action.SEND" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="image/*" /> <data android:mimeType="text/*" /> </intent-filter> </activity>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With