I have an app where I want to build 2 different flow\'s in:
1.b App show\'s an alertbox where user can choose to go to
A solution I just found does require a GET_TASK permission:
ActivityManager activityManager = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
List services = activityManager
.getRunningTasks(Integer.MAX_VALUE);
boolean isActivityFound = false;
if (services.get(0).topActivity.getPackageName().toString()
.equalsIgnoreCase(getApplicationContext().getPackageName().toString())) {
isActivityFound = true;
}
Log.d("GCM", "Activity open: "+isActivityFound);
UPDATE
In order to launch an alertbox (which isn't possible here) I created a custom alert box and let it use the AlertBox as theme. This is the activity in AndroidManifest.xml:
And the custom activity:
public class NotificationAlertActivity extends Activity implements
Observer, OnClickListener {
private String pendingObjectId;
private ModelFlag modelFlag;
private Database db;
private ArrayList discussions;
private ArrayList tips;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notification_alert);
findViewById(R.id.button_yes).setOnClickListener(this);
findViewById(R.id.button_no).setOnClickListener(this);
}
I updated the onHandleIntent with this bit:
if (isActivityFound) {
Intent dialogIntent = new Intent(getBaseContext(),
NotificationAlertActivity.class);
dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplication().startActivity(dialogIntent);
}