Question

I've made my app handle ACTION_VIEW intents for a certain data type, which it does fine. I can't seem to work out how to actually detect whether my app has been launched in this way though, and how to get at the attached data. Can someone point me in the right direction? Here's an excerpt from my manifest, if it helps.

<activity android:name=".MyApp"
          android:label="@string/app_name"
          android:screenOrientation="portrait" >

            ...

            <intent-filter>
              <action android:name="android.intent.action.VIEW"/>
              <action android:name="android.intent.action.EDIT" />
              <action android:name="android.intent.action.PICK" />
              <category android:name="android.intent.category.DEFAULT" />
              <data android:mimeType="audio/wav" />
            </intent-filter>


</activity>
Was it helpful?

Solution

You can retrieve the data URI from the intent's data:

Uri uri = getIntent() != null ? getIntent().getData() : null;

OTHER TIPS

Detect if this action started your app by using:

    String action = intent.getAction();
    if ( Intent.ACTION_VIEW.equals( action ) // watch out for action being null!
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top