Question : android notification addaction example
Answered by : abdoul
public class ActionReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) { //Toast.makeText(context,"recieved",Toast.LENGTH_SHORT).show(); String action=intent.getStringExtra("action"); if(action.equals("action1")){ performAction1(); } else if(action.equals("action2")){ performAction2(); } //This is used to close the notification tray Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); context.sendBroadcast(it);
}
public void performAction1(){
}
public void performAction2(){
}
}
Source : https://stackoverflow.com/questions/48260875/android-how-to-create-a-notification-with-action | Last Update : Wed, 24 Jun 20