DisplayMetrics dm = new DisplayMetrics();
context.getWindowManager().getDefaultDisplay().getMetrics(dm);
AppWidgetProviderInfo awpInfo = AppWidgetManager.getInstance(context).getAppWidgetInfo(appWidgetId);
int[] dimension = computeSpanForItem(dm,awpInfo.minWidth ,awpInfo.minHeight);
public int[] computeSpanForItem(DisplayMetrics dm,int width, int height){
float cell_w = 80*dm.density + 0.5f;
int spanX = (int) Math.ceil(width / cell_w);
int spanY = (int) Math.ceil(height / cell_w);
spanX = spanX > mColumn ? mColumn :spanX;
spanY = spanY > mRow ? mRow :spanY;
return new int[] { spanX, spanY };
}