创建桌面图标和删除桌面图标 android

第一步:设置文件添加权限:

   <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />

    <uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />

第二步:

<activity android:name=".AddShortCutActivity"
            android:label="@string/app_name">
      <intent-filter>
          <action android:name="android.intent.action.MAIN" />
          <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
        <intent-filter>
          <action android:name="android.intent.action.CREATE_SHORTCUT"></action>
      </intent-filter>
<intent-filter>
          <action android:name="android.intent.action.UNINSTALL_SHORTCUT"></action>
      </intent-filter>
  </activity>

第三步:

创建图标:

public static void createShortCut(Context context) {
final Intent addIntent = new Intent(
"com.android.launcher.action.INSTALL_SHORTCUT");
final Parcelable icon = Intent.ShortcutIconResource.fromContext(
context, R.drawable.ic_launcher); // 获取快捷键的图标
addIntent.putExtra("duplicate", false);
final Intent myIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
context.getString(R.string.addnewdiary));// 快捷方式的标题
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);// 快捷方式的图标
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, myIntent);// 快捷方式的动作
context.sendBroadcast(addIntent);
}
删除图标
private void delShortcut(Context context) {
Intent shortcut = new Intent(
"com.android.launcher.action.UNINSTALL_SHORTCUT");

// 快捷方式的名称
shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,
getString(R.string.app_name));

// 指定当前的Activity为快捷方式启动的对象: 如 com.everest.video.VideoPlayer
// 这里必须为Intent设置一个action,可以任意(但安装和卸载时该参数必须一致)
String action = "com.android.action.test";
// Intent respondIntent = new Intent(context, this.getClass());
// respondIntent.setAction(action);
// shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, respondIntent);

// 下面的方法与上面的效果是一样的,另一种构建形式而已
// 注意: ComponentName的第二个参数必须加上点号(.),否则快捷方式无法启动相应程序
String appClass = getActivity().getApplication().getPackageName() + "."
+ getActivity().getLocalClassName();
ComponentName comp = new ComponentName(getActivity().getApplication()
.getPackageName(), appClass);
shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT,
new Intent(action).setComponent(comp));
context.sendBroadcast(shortcut);
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Android Studio的桌面图标是指在桌面上显示的快捷方式图标。如果您已经安装了Android Studio,但是没有在桌面上看到它的图标,您可以按照以下步骤来创建一个桌面图标: 1. 打开Android Studio应用程序。 2. 在菜单栏中,选择“Tools”(工具)>“Create Desktop Entry”(创建桌面条目)。 3. 在弹出的窗口中,选择“Create”(创建)。 4. 现在,您应该能够在桌面上看到一个新的Android Studio图标。 如果您使用的是Linux操作系统,可能需要手动创建一个桌面图标。在这种情况下,您可以按照以下步骤操作: 1. 打开文本编辑器,创建一个新文件。 2. 将以下内容复制并粘贴到文件中: [Desktop Entry] Version=1. Type=Application Name=Android Studio Icon=/path/to/android-studio/bin/studio.png Exec="/path/to/android-studio/bin/studio.sh" %f Comment=The Integrated Development Environment for Android app development Categories=Development;IDE; Terminal=false StartupWMClass=jetbrains-android-studio 请注意,您需要将“/path/to/android-studio”替换为您的Android Studio安装路径。 3. 将文件保存为“android-studio.desktop”。 4. 将文件移动到“/usr/share/applications/”目录中。 5. 现在,您应该能够在桌面上看到一个新的Android Studio图标。 ### 回答2: Android Studio 是一款非常流行的 Android 应用开发工具,它是由 Google 投资和开发的一款强大的集成开发环境(IDE),帮助开发者创建高质量的 Android 应用程序。对于很多 Android 开发者而言,安装了 Android Studio 之后,他们就会想要在其对应的操作系统桌面环境下放置一个图标以便于使用。 Android Studio 桌面图标创建及使用方法是十分简单的,我们可以仿照其他软件创建桌面快捷方式的方式进行操作。首先在 Android Studio 安装目录下的 bin 目录,找到 studio.exe 文件,右键选择“发送到”,然后选择“桌面快捷方式”即可完成创建操作。之后我们就可以在操作系统的桌面上找到 Android Studio 的图标了。 如果在某些操作系统环境中,无法直接创建桌面快捷方式,那么我们可以手动创建一个快捷方式,将其拖拽到桌面上,从而完成 Android Studio 桌面图标创建操作。在Windows操作系统中,我们可以右键单击studio.exe文件,选择发送到“桌面(快捷方式)”\;在Mac操作系统中,我们可以右键单击studio.exe文件,选择“创建别名”,并将别名拖放到桌面上以完成操作。此外,使用者也可以很方便地在Web搜索引擎上搜索相关关键词,查阅更为详尽的技术介绍。 ### 回答3: Android Studio是一个为Android开发者设计的集成开发环境(IDE)。它能够帮助开发者在Android平台上构建高质量的应用程序。通过使用Android Studio,开发者可以使用Java或Kotlin编程语言来构建Android应用程序。 当我们安装好Android Studio后,通常会在桌面上出现一个图标。点击这个图标便可以打开Android Studio。默认情况下,这个桌面图标会安装在操作系统的程序菜单中,在运行时会在任务栏中显示。 除了使用桌面图标,也可以通过在终端运行“studio.sh”命令来打开Android Studio。 如果您希望在桌面创建Android Studio的快捷方式,可以通过以下步骤实现: 1.右键单击桌面并选择“创建新文件夹”。您可以将此文件夹命名为“Android Studio”。 2.在“Android Studio”文件夹内右键单击并选择“创建启动器”。 3.在“创建启动器”窗口中,输入以下信息: -名称:Android Studio -命令:/ home / <USER_NAME> / android-studio / bin / studio.sh(<USER_NAME>是您的用户名) 4.单击“应用”按钮以完成创建过程。 现在,您可以双击桌面上的快捷方式,打开Android Studio并开始开发您的Android应用程序。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值