当前位置: 代码迷 >> Android >> Android,桌面快捷方式toast屏蔽有关问题?
  详细解决方案

Android,桌面快捷方式toast屏蔽有关问题?

热度:42   发布时间:2016-05-01 17:50:57.0
Android,桌面快捷方式toast屏蔽问题?急急急!!!!在线等!!!!
Intent shortcut = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
  shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, "创建啦");
  shortcut.putExtra("duplicate", false); // 不允许重复
  ComponentName comp =new ComponentName(this.getPackageName(), "."+this.getLocalClassName());
  shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(Intent.ACTION_MAIN).setComponent(comp));
  ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(this,R.drawable.icon);
  // 设置快捷方式的图标
  shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes); 
  // 定义shortcut点击事件
  sendBroadcast(shortcut);


这段代码可以实现桌面快捷方式的创建,但是每当创建成功的时候都会提示快捷方式已经创建成功的Toast提示,我想让这个提示取消,屏蔽这个Toast,应该怎么做,请各位高手给个方法!!!!!!

------解决方案--------------------
这个Toast的提示是在Launcher源码里面,想要屏蔽必须修改Launcher的源码!Launcher源码的InstallShortcutReceiver这个类里面, /* Toast.makeText(context, context.getString(R.string.shortcut_installed, name),
Toast.LENGTH_SHORT).show();*/ 这句!
  相关解决方案