So before people run and say thats its a duplicate let me explain.
I have an app which is basically a launcher in a tablet for a car. When ever I get a message from the server I show it as a pop up dialog with the below code -
public void openMessage(MsgItem msg)
{
Intent intent = new Intent(_context, MainActivity.class);
intent.putExtra(MainActivity.OP_EXTRA_MESSAGE, msg);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
_context.startActivity(intent);
}
Now you can see it returns to the MainActivity and then shows the pop up there.
I want the app to be able to show the pop up on what ever app is running inside it. That means if the user opened Waze app from the launcher and there is a pop up, it will show on the Waze activity and won't take me to the MainActivity first.
How can I fetch what app/activity is opened for this purpose? There are several apps that could be opened from the launcher beside the waze.
I saw other answers regarding the instances of the activities and such, but I didn't manage to implement anything in my code.