Reputation: 1
I try to code an app, which can receive images from gallery via Share Dialog and can be started normally I have an Activity with is opening by Share Dialog to receive Images. For this issue, I have following code:
if (!getIntent().getExtras()==(null))
Uri imageUri = (Uri) getIntent().getExtras().get(Intent.EXTRA_STREAM);
Now I want to start this Activity also normally. It works. But is this good practice to check if Extra_Stream is null or not null to check how the activity was started? And how can I check more specify? I mean other Types of Extras can be involved. So a key would be helpful. But I don´t know how, because I realized that in the Manifest.
To Enable Share-Dialog I have following in the Manifest
<activity android:name=".Setup" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
Upvotes: 0
Views: 422
Reputation: 20346
You can check value of the action.
if (Intent.ACTION_SEND.equals(getIntent().getAction())) {
// code specific for ACTION_SEND
}
Upvotes: 1