创建桌面快捷方式

来源:互联网 发布:配音秀软件 编辑:程序博客网 时间:2024/05/30 04:56
  • .添加权限:
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
  • 代码实现:
Intent intent = new Intent();intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");//这个intent可以做任何事情,不单单是打电话Intent dowhtIntent = new Intent();//告诉系统打电话dowhtIntent.setAction(Intent.ACTION_CALL);//设置电话号码dowhtIntent.setData(Uri.parse("tel://13886562052"));//设置快捷方式的名字intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "这是快捷方式");//设置快捷方式图片intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher));//设置快捷方式的意图intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT,dowhtIntent);//发送广播sendBroadcast(intent);
原创粉丝点击