APP生成桌面快捷方式

在启动页oncreate()方法通过发送广播给桌面可创建快捷方式

//从sharepreference检查是否创建过
boolean isInstalled = SpUtil.getBoolean(getApplicationContext(), Constacts.SHORTCUT, false);
        if (!isInstalled) {
            Intent intent = new Intent();
            intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
            intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "应用名称");
            intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));//The name of the extra used to define the icon, as a Bitmap, of a shortcut.
            Intent startIntent = new Intent();
            startIntent.setAction("android.intent.action.MAIN");
            startIntent.addCategory("android.intent.category.LAUNCHER");
            startIntent.addCategory("android.intent.category.DEFAULT");
            startIntent.addCategory("android.intent.category.TAB");
            intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, startIntent);
            sendBroadcast(intent);
            //已创建,添加到sharepreference
            SpUtil.putBoolean(getApplicationContext(), Constacts.SHORTCUT, true);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在 Debian 系统中,deb 安装包一般是通过 dpkg 工具进行安装的。而要在安装 deb 包时自动生成桌面快捷方式,可以在 deb 包的控制文件中添加必要的配置信息。 具体来说,可以在 `debian/control` 文件中添加如下信息: ``` Package: your-package-name Version: your-package-version Section: utils Priority: optional Architecture: all Depends: your-dependencies Maintainer: your-name <your-email> Description: your-package-description Homepage: your-package-homepage # 添加以下内容即可自动生成桌面快捷方式 # 这里以 Gnome 桌面环境为例 X-GNOME-Autostart-enabled: true X-GNOME-Autostart-Delay: 5 X-GNOME-Autostart-Notify: true X-GNOME-Autostart-Phase: Application X-GNOME-Autostart-Name: your-app-name X-GNOME-Autostart-Comment: your-app-description X-GNOME-Autostart-Icon: your-app-icon X-GNOME-Autostart-Exec: your-app-executable ``` 上述配置信息中,`X-GNOME-Autostart-enabled` 用于指定是否启用自动启动,`X-GNOME-Autostart-Delay` 是启动时的延迟时间,`X-GNOME-Autostart-Notify` 是否在启动时显示通知,`X-GNOME-Autostart-Phase` 是启动时的阶段,`X-GNOME-Autostart-Name` 是快捷方式的名称,`X-GNOME-Autostart-Comment` 是快捷方式的描述,`X-GNOME-Autostart-Icon` 是快捷方式的图标,`X-GNOME-Autostart-Exec` 是启动应用程序的命令。 添加完控制文件后,通过 dpkg-buildpackage 命令打包生成 deb 安装包,并在安装时指定 `--install` 参数,例如: ``` sudo dpkg -i your-package-name.deb --install ``` 安装完成后,就会自动在桌面生成一个快捷方式。需要注意的是,上述配置仅适用于 Gnome 桌面环境,其他桌面环境可能需要不同的配置。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值