- function:
Displays the shortcut creation dialog and launches, if necessary, the
appropriate activity
通过一个AddAdpter加入到一个list中,创建menu中ADD的功能:
1.创建dialog
mAdapter = new AddAdapter(Launcher.this);
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setAdatper(mAddapter,this);
AlertDialog dialog = builder.create(); dialog.setOnCancelListener(this);
2.创建dialog的监听 主要监听以下动作:
- AddAdapter.ITEM_SHORTCUT
pickIntent.putExtra(Intent.EXTRA_INTENT, new Intent(Intent.ACTION_CREATE_SHORTCUT));//加入
EXTRA_INTENT
- AddAdapter.ITEM_APPWIDGET//打开所有widget的dialog
Intent pickIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_PICK);
ArrayList<AppWidgetProviderInfo> customInfo = new ArrayList<AppWidgetProviderInfo>();
pickIntent.putParcelableArrayListExtra(AppWidgetManager.EXTRA_CUSTOM_INFO, customInfo);
通过上面四步就可以得到相应的widget dilaog
- AddAdapter.ITEM_LIVE_FOLDER//打开folder的dialog
pickIntent.putExtra(Intent.EXTRA_TITLE,getText(R.string.title_select_live_folder));
pickIntent.putExtra(Intent.EXTRA_INTENT, newIntent(LiveFolders.ACTION_CREATE_LIVE_FOLDER));
- AddAdapter.ITEM_WALLPAPER//打开wallppaper的选择器diaog
final Intent pickWallpaper = new Intent(Intent.ACTION_SET_WALLPAPER);//Action 为SET_wallpaper
startActivity(Intent.createChooser(pickWallpaper,getString(R.string.chooser_wallpaper)))选择器