package com.example.noti;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
// TODO Auto-generated method stub
if(intent==null||intent.getAction()==null)
return;
String action=intent.getAction();
if(action.compareTo("hello")==0)
{
Intent it= new Intent(getApplicationContext(),Constants.class);
it.setAction("hello");
PendingIntent pt=PendingIntent.getService(getApplicationContext(), 1, it, 0);
Intent it1= new Intent(getApplicationContext(),Constants.class);
it.setAction("hello1");
PendingIntent pt1=PendingIntent.getService(getApplicationContext(), 2, it1, 0);
Notification.Builder builder=new Notification.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(hello())
.setContentText("inside")
.addAction(R.drawable.pre,"",pt)
.addAction(R.drawable.next,"",pt1);
NotificationManager nm=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(1,builder.build());
handleIntent(intent);
//return super.onStartCommand(intent, flags, startId);
}
if(action.compareTo("hello1")==0)
{
Intent it= new Intent(getApplicationContext(),Constants.class);
it.setAction("hello");
PendingIntent pt=PendingIntent.getBroadcast(getApplicationContext(), 0, intent, 0);
Notification.Builder builder=new Notification.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Main")
.setContentText("inside21")
.addAction(R.drawable.pre,"",null)
.addAction(R.drawable.next,"", pt);
NotificationManager nm=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(2,builder.build());
}
}
Here is my code which i had written till now. Basically i want two buttons in my notification bar i.e. next and previous(pre). it works same like media player,major change is that when press next it show new notification and again same thing. and previous button shows previous notification, not the activity.