I am trying to open an app when a push notification is received.
Code:
public class GCMIntentService extends GCMBaseIntentService {
public GCMIn
public void getnotification(View view) {
NotificationManager notificationmgr =(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Intent intent = new Intent(this,resultpage.class);
PendingIntent p = PendingIntent.getService(this,(int) System.currentTimeMillis(),intent,0);
Notification n = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
n = new Builder(this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("Hello android user here")
.setContentText("welcome to notification serrvice")
.setContentIntent(p)
.build();
notificationmgr.notify(0,n);
}
PackageManager.getLaunchIntentForPackage can help you find the entry activity.
Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(launchIntent);
Its the class that implements the activity you wish to launch. LoginActivity, MainActivity, whatever it was you named it.