Find which application launched my activity

Other applications may select files from my application.

<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 the file back to the requested application

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

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

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

can someone help me find it. I use lollipop, so the getTask trick will not work. HELP!

+4
source share
1 answer

Use getCallingActivity().getClassName()

-one
source

All Articles