I read about documentation of android and used following code to send a notification
protected void sendnotification(String result2) {
// TODO Auto-generated method stub
nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Intent intent = new Intent(this,test.class);
PendingIntent pi = PendingIntent.getActivity(this, 0, intent, 0);
String body = "Hi this is test";
String title = "Ritu";
Notification n = new Notification(R.drawable.icon,result2,System.currentTimeMillis());
n.setLatestEventInfo(this, title, result2, pi);
n.defaults = Notification.DEFAULT_LIGHTS;
nm.notify(uniqueid, n);
}
What I got from documentation is that test activity will be launched when I click on the notification, but instead it is opening the application’s activity from where it was called. Please correct me if I am wrong.
Thanks
What you have done USED to be the code for this mission, but its deprecated now – both the constructor you used to create the Notification object, and the setLatestEventInfo method.
You should add the flag ‘FLAG_ACTIVITY_NEW_TASK’ when creating your intent, and use the Notification.Builder class to create your notification.