private void createShortcut(String title, String url) {
Intent intent = new Intent(INSTALL_SHORTCUT);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Baidu");
Intent shortcutIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
long urlHash = url.hashCode();
long uniqueId = (urlHash << 32) | shortcutIntent.hashCode();
shortcutIntent.putExtra("com.android.browser.application_id", Long.toString(uniqueId));
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
sendBroadcast(intent);
}
Android通过代码创建快捷方式
最新推荐文章于 2024-06-20 13:52:17 发布