android notification addaction example

Solutions on MaxInterview for android notification addaction example by the best coders in the world

showing results for - "android notification addaction example"
Angelo
10 Aug 2016
1public class ActionReceiver extends BroadcastReceiver {
2
3@Override
4public void onReceive(Context context, Intent intent) {
5
6    //Toast.makeText(context,"recieved",Toast.LENGTH_SHORT).show();
7
8    String action=intent.getStringExtra("action");
9    if(action.equals("action1")){
10        performAction1();
11    }
12    else if(action.equals("action2")){
13        performAction2();
14
15    }
16    //This is used to close the notification tray
17    Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
18    context.sendBroadcast(it);
19}
20
21public void performAction1(){
22
23}
24
25public void performAction2(){
26
27}
28}