I am trying to launch a new activity on click of notification. But problem is that notification intent is not working and when i click on notification it do nothing. Means its not launch new activity(Notificationjump.class).
Here is my code
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button)findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
notrify();
}
});
}
private void notrify() {
int notificationid = 001;
NotificationManager mNotifyManager =(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Intent resultintent = new Intent(getApplicationContext(),Notificationjump.class);
resultintent.setAction(Intent.ACTION_VIEW);
// resultintent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent resultPendingIntent = PendingIntent.getActivity(this,1,resultintent,PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.notify)
.setContentTitle("Mynotification")
.setContentText("Hello world");
mBuilder.setContentIntent(resultPendingIntent);
mBuilder.setOngoing(true);
mNotifyManager.notify(notificationid,mBuilder.build());
}
Here is my Notificationjump.class
package com.example.notification;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
public class Notificationjump extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.notifyjump);
System.out.println("hellllllllllllo");
finish();
}
}
Can somebody tell me why pending intent is not working?