Android: how to start the app intalled in the phone using the packagename and pass it a parameter?
I HAVE REEDITED THE QUESTION
I am getting the apps installed in the Android phone with the code below. I put the info of the app in an instance of PInfo (one of my customized class).
Now I want to get one of them and open it passing a parameter, I have tried the following:
Uri uri =Uri.parse("THEURL");
Intent intent = getPackageManager().getLaunchIntentForPackage(((PInfo)apps.get(0)).apppackage);
intent.setData(uri);
startActivity(intent);
This opens the开发者_C百科 app but how to pass the parameter? (The code above is not working) For example, a string.
Step #1: Get the email address of the developer of the application in question.
Step #2: Ask the developer if they support such a string extra (or data Uri
, or whatever). If so, follow what they tell you to do. If not, do not attempt to open their app this way.
Step #3: Repeat Steps #1 and #2 for every app you are interested in.
You should create a method that handles the incoming intent and call it within your onCreate
or onResume
methods.
You'll pass the information like this:
intent.putExtra("foo", someString);
Then you'll try read the information passed along within the intent.
String incomingString = getIntent().getStringExtra("foo");
should do the trick within your handleIncomingIntent()
精彩评论