解决方法
我正在回答Frankish的回答,我是如何处理这个广播的:
@Override public void onReceive(Context context,Intent intent) { // Handle TouchWiz if(intent.getAction().contentEquals("com.sec.android.widgetapp.APPWIDGET_RESIZE")) { handleTouchWiz(context,intent); } super.onReceive(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 > 0 && widgetSpanX > 0 && widgetSpanY > 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); } }
如果您使用的是MAX_HEIGHT或MAX_WIDTH,则可能需要更改处理该捆绑包的方式.