i need to send to foreground one activity that i've put in background by typing:
- Code: Select all
moveTaskToBack(true);
This activity have one active notification so with the following code i can put the activity in foreground again.
- Code: Select all
Intent notificationIntent = new Intent(this, IDontDisturbActivity.class);
notificationIntent.setAction("android.intent.action.MAIN");
notificationIntent.addCategory("android.intent.category.LAUNCHER");
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
notification.flags=notification.FLAG_FOREGROUND_SERVICE;
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
But if i don't launch the main activity manually, and the activity is launched on the system startup by this code there is no way to get the activity in foreground again.
- Code: Select all
public class BootUpReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context, IDontDisturbActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
Any suggestion is welcome.
Lorenzo


