1

I saw in documentation:

EXTRA_APPWIDGET_PREVIEW

An extra that can be passed to requestPinAppWidget(android.content.ComponentName, android.os.Bundle, android.app.PendingIntent).

So I tried to something like:

...
Bundle b = new Bundle();
b.putInt(AppWidgetManager.EXTRA_APPWIDGET_PREVIEW, R.drawable.preview_new);
appWidgetManager.requestPinAppWidget(myWidgetProvider, b, successCallback);

But seems like bundle b is completely ignored (it doesnt change preview).

What am I doing wrong?

1 Answer 1

4

Replace your Bundle with :

Bundle b = new Bundle();
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.widget_layout);
b.putParcelable(AppWidgetManager.EXTRA_APPWIDGET_PREVIEW, remoteViews);

Ref : https://medium.com/wearebase/android-oreo-widget-pinning-in-kotlin-398d529eab28

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.