I’m making an application starting others installed applications on an Android smartphone.
Basically, here is the code i use to start another application made by myself, with a parameter.
Application 1 :
PackageManager pm = getApplicationContext().getPackageManager();
Intent appStartIntent = pm.getLaunchIntentForPackage(mypackage);
appStartIntent.putExtra("message", s);
if (null != appStartIntent) {
getApplicationContext().startActivity(appStartIntent);
}
In my other application, here how i get the parameter :
Appliaction 2 :
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Bundle extras = getIntent().getExtras();
String result;
try {
result= (String) extras.getString("message");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
recup = "nothing received";
}
Toast.makeText(getApplicationContext(), recup, Toast.LENGTH_SHORT).show();
}
The problem here, is that we need to know the second application can receive a parameter called “message”.
Here is the question :
Is it possible to know all possible parameters expected by the application 2, from the application 1 ?
If yes, is it possible to know for example, the parameters accepted by any installed application on my phone? (example : Handcent, Facebook, latitude…)
Android doesn’t define a metadata API that will allow you to retrieve the parameters an application is expecting. Thus, it isn’t possible to do what you want. You will have to rely on the documentation of each application.