Skip to content

Commit 71c7a97

Browse files
Widget: PendingIntent.FLAG_MUTABLE requires Android S or more
Issue #142 Signed-off-by: sunilpaulmathew <[email protected]>
1 parent 1141f98 commit 71c7a97

File tree

1 file changed

+5
-6
lines changed
  • app/src/main/java/com/smartpack/kernelmanager/services/profile

1 file changed

+5
-6
lines changed

app/src/main/java/com/smartpack/kernelmanager/services/profile/Widget.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@
4747
*/
4848
public class Widget extends AppWidgetProvider {
4949

50-
private static final String TAG = Widget.class.getSimpleName();
51-
5250
private static final String LIST_ITEM_CLICK = "list_item";
5351
private static final String ITEM_ARG = "item_extra";
5452

@@ -64,17 +62,18 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a
6462
RemoteViews widget = new RemoteViews(context.getPackageName(), R.layout.widget_profile);
6563
widget.setRemoteAdapter(R.id.profile_list, svcIntent);
6664

67-
widget.setPendingIntentTemplate(R.id.profile_list, getPendingIntent(context, LIST_ITEM_CLICK));
65+
widget.setPendingIntentTemplate(R.id.profile_list, getPendingIntent(context));
6866

6967
appWidgetManager.updateAppWidget(appWidgetId, widget);
7068
}
7169
}
7270

73-
private PendingIntent getPendingIntent(Context context, String action) {
71+
private PendingIntent getPendingIntent(Context context) {
7472
Intent intent = new Intent(context, getClass());
75-
intent.setAction(action);
73+
intent.setAction(LIST_ITEM_CLICK);
7674
return PendingIntent.getBroadcast(context, 0, intent, Build.VERSION.SDK_INT >=
77-
android.os.Build.VERSION_CODES.M ? PendingIntent.FLAG_MUTABLE : 0);
75+
android.os.Build.VERSION_CODES.M ? Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S ?
76+
PendingIntent.FLAG_MUTABLE : PendingIntent.FLAG_IMMUTABLE: 0);
7877
}
7978

8079
@Override

0 commit comments

Comments
 (0)