您的位置:首页 > 其它

创建桌面快捷方式

2017-09-25 17:22 148 查看
.添加权限:

<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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: