Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To add to Artem's answer, you can get your new options out of the bundle by doing the following.</p> <pre><code>public class YourWidgetProvider extends AppWidgetProvider { @Override public void onAppWidgetOptionsChanged (Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) { // This is how you get your changes. int minWidth = newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH) int maxWidth = newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH) int minHeight = newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT) int maxHeight = newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT) } } </code></pre> <p>Then unfortunatly things are never that easy on Android. TouchWiz (Samsung's galaxy line) does not make this call, but we can get their broadcast. So in your AppWidgetProvider class do the following:</p> <pre><code>@Override public void onReceive(Context context, Intent intent) { // Handle TouchWiz if(intent.getAction().contentEquals("com.sec.android.widgetapp.APPWIDGET_RESIZE")) { handleTouchWiz(context, intent); } } private void handleTouchWiz(Context context, Intent intent) { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context); int appWidgetId = intent.getIntExtra("widgetId", 0); int widgetSpanX = intent.getIntExtra("widgetspanx", 0); int widgetSpanY = intent.getIntExtra("widgetspany", 0); if(appWidgetId &gt; 0 &amp;&amp; widgetSpanX &gt; 0 &amp;&amp; widgetSpanY &gt; 0) { Bundle newOptions = new Bundle(); // We have to convert these numbers for future use newOptions.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, widgetSpanY * 74); newOptions.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, widgetSpanX * 74); onAppWidgetOptionsChanged(context, appWidgetManager, appWidgetId, newOptions); } } </code></pre> <p>You may need to change how you handle that bundle if you are using MAX_HEIGHT or MAX_WIDTH which I am not.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload