My app is registering an intent to receive URLs so when the user shares a url, my app will be in the list of apps.
<intent-filter
android:label="my app">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
-
in my MainActivity's onCreate() method:
String action = intent.getAction();
if (action.equalsIgnoreCase(Intent.ACTION_SEND)) {
Uri data = intent.getData();
String s = data.toString();
output.setText(s); //output: a TextView that holds the URL
}
-
The problem I got is: data is null which is strange. Since this code works perfectly with ACTION_VIEW
. However, it didn't work with ACTION_SEND
.
How could I modify it to work?
You can try