0

My app receives and analyze data from received intent (ACTION.SEND). Intent has many details in extras depending upon the application.

What I want is packageID of application from which my has received the intent?

Is there any standard way to achieve this?

user2095470
  • 356
  • 1
  • 6
  • 23

2 Answers2

0

If you need this application details in many activities of your application, you could save them into the Shared preferences and use them from all of the activities without passing them each time as extras in an intent. You could do it this way for example:

SharedPreferences.Editor editor = getSharedPreferences(preffName, MODE_PRIVATE).edit(); //preffName is a String variable with the name of your preferences - just use the same string every time 
editor.putString("AppName", "MyApplication");
editor.putInt("PackageID", "MyPackageID");
editor.commit();

And then you could get the saved data like this:

SharedPreferences prefs = getSharedPreferences(preffName, MODE_PRIVATE); 
String appName = prefs.getString("AppName", "No name defined");//"No name defined" is the default value.
String packageID = prefs.getString("PackageID", "No package id is defined."); //"No package id is defined" is the default value
Gabriella Angelova
  • 2,985
  • 1
  • 17
  • 30
  • I think you are not getting my question. I want package info of any app who sends Action.SEND intent and My app receive that intent. – user2095470 Jun 24 '15 at 07:58
  • Then maybe this tutorial could be helpful for you http://code.tutsplus.com/tutorials/android-sdk-receiving-data-from-the-send-intent--mobile-14878 – Gabriella Angelova Jun 24 '15 at 08:03
  • this what all I have already implemented. Reading action type, reading MIME etc. I am already doing all this and working fine. It doesn't show how to get packageInfo of send app. – user2095470 Jun 24 '15 at 08:06
0

After reading this How to find Intent source in Android? it seems impossible or very tricky solution. There is no direct way to achieve this. Ahh Android.

Community
  • 1
  • 1
user2095470
  • 356
  • 1
  • 6
  • 23