Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Get File that Opened Activity with Intent Filter

I added an intent filter to my activity for a specific type of mime and extension, so when I click on that file it opens the activity that is supposed to open.

Thats awesome, and its working!

But how can I get the file that I clicked? I guess that its possible.

Can someone give me some hints? Thanks alot in advance ;)

EDIT:

I Have this on my AndroidManifest.xml

        <activity
            android:name="com.activities.omega1.SlaveLoadConfig"
            android:label="@string/title_activity_slave_load_config"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="file" />
                <data android:mimeType="*/*" />
                <data android:pathPattern=".*\\.sso" />
                <data android:host="*" />
            </intent-filter>
        </activity>

And I already have files with extension .sso opening the SlaveLoadConfig activity, but I would like to have an handler to get the content of the file, how ?

like image 350
TiagoM Avatar asked Mar 15 '26 01:03

TiagoM


1 Answers

Found the solution :P

Intent intent = getIntent();
intent.getData().toString();
like image 92
TiagoM Avatar answered Mar 17 '26 15:03

TiagoM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!