How to launch an Activity from another Application in Android
To launch an activity from another application in Android, you can use an Intent
with the FLAG_ACTIVITY_NEW_TASK
flag set.
Here's an example of how to launch an activity from another application:
Intent intent = new Intent(context, TargetActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
Here, context
is the Context
of the current application, and TargetActivity
is the class of the activity that you want to launch.
If you want to pass data to the target activity, you can use putExtra
method on the Intent
object to add data to the intent. For example:
intent.putExtra("key", "value");
You can then retrieve the data in the target activity using the getIntent
method and the getStringExtra
method:
String value = getIntent().getStringExtra("key");
I hope this helps! Let me know if you have any questions.