Widget sending multiple types of intents

后端 未结 3 1642
一生所求
一生所求 2020-12-18 15:57

I am building a widget that has multiple buttons, each one sending off its own intent to a broadcast receiver. The broadcast receiver is suppose to display a Toast message b

3条回答
  •  我在风中等你
    2020-12-18 16:19

    you need to provide seperate request code for each pendingintent ex:

    PendingIntent pendingIntent1 = PendingIntent.getBroadcast(context, 0, intent1, PendingIntent.FLAG_UPDATE_CURRENT); 
    PendingIntent pendingIntent1 = PendingIntent.getBroadcast(context, 1/*request code*/, intent1, PendingIntent.FLAG_UPDATE_CURRENT);
    

提交回复
热议问题