android桌面快捷方式添加 删除 更新 自动运行
来源:互联网 发布:中国广电网络客服电话 编辑:程序博客网 时间:2024/05/15 10:23
添加快捷方式 <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
Intent shortcutIntent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME,getString(R.string.app_name));
shortcutIntent.putExtra("duplicate", false);
Intent intent = new Intent();
intent.setComponent(new ComponentName(getPackageName(), MainActivity.class.getName()));
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,Intent.ShortcutIconResource.fromContext(this, R.drawable.icon));
sendBroadcast(shortcutIntent);
public class BootReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
//接收广播:系统启动完成后运行程序
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
Intent newIntent = new Intent(context, searchDemo.class);
newIntent.setAction("android.intent.action.MAIN");
newIntent.addCategory("android.intent.category.LAUNCHER");
newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(newIntent);
}
//接收广播:设备上新安装了一个应用程序包后自动启动新安装应用程序。
if (intent.getAction().equals("android.intent.action.PACKAGE_ADDED")) {
String packageName = intent.getDataString().substring(8);
System.out.println("---------------" + packageName);
Intent newIntent = new Intent();
newIntent.setClassName(packageName,packageName+ ".searchDemo");
newIntent.setAction("android.intent.action.MAIN");
newIntent.addCategory("android.intent.category.LAUNCHER");
newIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(newIntent);
}
//接收广播:设备上删除了一个应用程序包。 :这个貌似需要root权限
<uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT"/>
if (intent.getAction().equals("android.intent.action.PACKAGE_REMOVED")) {
String ACTION_UNINSTALL_SHORTCUT ="com.android.launcher.action.UNINSTALL_SHORTCUT";
Intent intent3 = new Intent(ACTION_UNINSTALL_SHORTCUT );
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, R.string.app_name);
// 要删除的应用程序的ComponentName,即应用程序包名+activity的名字
ComponentName comp = new ComponentName("搜索","searchDemo");
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent()
.setComponent(comp).setAction("android.intent.action.MAIN"));
context.sendBroadcast(intent);
}
}
- android桌面快捷方式添加 删除 更新 自动运行
- android添加删除桌面快捷方式
- 【Android】添加删除桌面快捷方式
- android添加删除桌面快捷方式
- Android添加桌面快捷方式和删除桌面快捷方式
- Android 添加和删除桌面快捷方式
- android自动添加程序桌面快捷方式
- android桌面添加快捷方式
- Android添加桌面快捷方式
- android 添加桌面快捷方式
- Android 为应用创建多个桌面快捷方式,可在卸载时自动删除桌面快捷方式
- Android程序首次运行自动创建桌面快捷方式的方法
- Android桌面 快捷方式的删除
- 【ANDROID】创建/删除桌面快捷方式
- Android 向桌面添加快捷方式
- Android 向桌面添加快捷方式
- Android 向桌面添加快捷方式
- Android 添加桌面快捷方式操作
- ERROR: the user data image is used by another emulator. aborting错误!
- 100个java程序员常去的网站
- 错误总结
- C++防止内存泄露问题发生
- HDU 1856 并查集
- android桌面快捷方式添加 删除 更新 自动运行
- CSS选择器总结
- Ogre中mesh共享顶点缓存的使用
- Linux下使用readdir查找文件
- fcntl函数中的建议性锁和强制性锁
- myeclipse快捷键
- 在Canvas上画出任意长宽比例,旋转任意角度的,带反走样算法(anti-aliased)的字符串
- start_kernel->setup_arch->paging_init-->free_area_init_node 之 2
- 游戏程序员成长