0

I have a widget in android that works correctly when I set targetSdk<26, but when I set targetSdk>=26 onReceive() doesn't fired and my widget doesn't update.
i don't know what's wrong with that?

I used below code to update my widget in button click.

updateViews.setOnClickPendingIntent(R.id.age_rotated_layout_larg, getPendingIntent(context, MOVE, appWidgetId));

private PendingIntent getPendingIntent(Context context,String action,int id) { Intent intent = new Intent(action);

  intent.putExtra("ID", id);

  PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 
 id,intent,PendingIntent.FLAG_UPDATE_CURRENT);    
 return pendingIntent;

}

yasin
  • 126
  • 6
  • 2
    You're using an implicit `Intent`; i.e., one for which you've only set an action. Since Oreo, most implicit `Intent`s don't work for Receivers registered in the manifest. You simply need to change your `Intent` to an explicit one, by specifying the target class; e.g., `Intent intent = new Intent(context, YourReceiver.class);`. You can then remove the corresponding ``/`` in the manifest. That's really what you should've been doing all along, btw. Always use an explicit `Intent` when possible. – Mike M. Aug 31 '19 at 06:02
  • 1
    thankyou Mike.you're right. – yasin Aug 31 '19 at 08:03

0 Answers0