0

I would need to get the widget id inside the BroadcastReceiver.

I'm trying everything, below you see what I get.

I also followed: Get widget id from BroadcastReceiver

But I don't understand what I'm doing wrong.

Can you give me a hand?

public class WidgetService extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {

        int[] a = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
        int b = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
        String c = intent.getStringExtra(AppWidgetManager.EXTRA_APPWIDGET_ID);
        Log.d("a", String.valueOf(a));
        Log.d("b", String.valueOf(b));
        Log.d("c", String.valueOf(c));
....

Console:

a   com.app.name   D  null
b   com.app.name   D  -1
c   com.app.name   D  null
Paul
  • 3,644
  • 9
  • 47
  • 113

0 Answers0