So if I want to start application B from application A I can do something similar to this:
Now to get the "data" extra field I can do this in com.mypackage.StartActivity
nCreate() { ...
Intent intent = getIntent();
String data = intent.getStringExtra("data");
System.setProperty("data", data);
...
However... My question is that this works fine when the application is not running, however if it is a running application and its current activity is not "StartActivity", then StartActivity
nCreate() will not be called (nor will its onResume). I'm trying to avoid adding the above logic to every single Activities onResume() method. Is there a method that always gets called? I don't really want to register a service for this intent either, if I can avoid it.
Thanks!
Intent intent = new Intent();
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("data", mydata);
intent.setClassName("com.mypackage", "com.mypackage.StartActivity");
context.startActivity(intent);
And that will launch application B as if I pressed its icon in the launcher.intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("data", mydata);
intent.setClassName("com.mypackage", "com.mypackage.StartActivity");
context.startActivity(intent);
Now to get the "data" extra field I can do this in com.mypackage.StartActivity
nCreate() { ...Intent intent = getIntent();
String data = intent.getStringExtra("data");
System.setProperty("data", data);
...
However... My question is that this works fine when the application is not running, however if it is a running application and its current activity is not "StartActivity", then StartActivity
nCreate() will not be called (nor will its onResume). I'm trying to avoid adding the above logic to every single Activities onResume() method. Is there a method that always gets called? I don't really want to register a service for this intent either, if I can avoid it.Thanks!