launcher -->CreateShortcut.java

  1.  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
Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY);//Pick an activity given an intent, returning the class selected
pickIntent.putExtra(Intent.EXTRA_INTENT, new Intent(Intent.ACTION_CREATE_SHORTCUT));//加入 EXTRA_INTENT
  • AddAdapter.ITEM_APPWIDGET//打开所有widget的dialog
pickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,appWidgetId);
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
Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY);
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)))选择器

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值