, :
Intent notificationIntent = new Intent(this, MainActivity.class);
notificationIntent.setAction(Intent.ACTION_MAIN);
notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
notificationIntent.putExtra("screen", "debugScreen");
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
NotificationManager nMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
PendingIntent intent2 = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder nBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Some Title")
.setContentText("Some text")
.setContentIntent(intent2)
.setAutoCancel(true);
nMgr.notify(0, nBuilder.build());
onNewIntent:
@Override
public void onNewIntent(Intent intent){
Bundle extras = intent.getExtras();
String tabNumber;
if(extras != null) {
tabNumber = extras.getString("screen");
Log.d("TEMP", "Tab Number: " + tabNumber);
} else {
Log.d("TEMP", "Extras are NULL");
}
}
, , .
, , , activityToShow. , Intent.putExtra(...) , , , Integer, .
activityToShow , , ( ), , .
, .