简体   繁体   中英

Find which application launched my Activity

Other applications can select files from my app.

 <activity
            android:name="xxxx"
            android:icon="@drawable/xx"
            android:label="@string/title_activity_select_secure_cloud_drive_file_chooser" >
            <intent-filter>
                <action android:name="android.intent.action.PICK" />

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

                <data android:scheme="file" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.GET_CONTENT" />
                <category android:name="android.intent.category.OPENABLE" />
                <category android:name="android.intent.category.DEFAULT" />

                <data android:mimeType="*/*" />
            </intent-filter>
        </activity>

I send back the file to the requested app

result.setData(uri);
setResult(Activity.RESULT_OK, result);

everything is working fine. Now i need to know who is calling my application? eg (mail, dropbox ... etc)

i tried getCallingActivity() it did not work always returns com.android.documentsui.DocumentsActivity

can anyone help me find it. I'm using lollipop so the getTask trick won't work. HELP !

使用getCallingActivity().getClassName()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM