是否可以要求网站访问者将您的网站保存在他们的主屏幕上? 机器人
答案 0 :(得分:0)
在此处查看此答案,了解如何创建快捷方式:
How to add android bookmark on homescreen from web page?
如果您正在编写Android应用,则可以使用此方法。但是,如果这是一个网站,这种方法将无法工作,因为看起来Android Intent系统忽略了网站生成的操作。
您可以使用此代码在主屏幕上创建网页快捷方式。提供必要的信息,如网址,标题等。
final Intent in = new Intent();
final Intent shortcutIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
long urlHash = url.hashCode();
long uniqueId = (urlHash << 32) | shortcutIntent.hashCode();
shortcutIntent.putExtra(Browser.EXTRA_APPLICATION_ID, Long.toString(uniqueId));
in.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
in.putExtra(Intent.EXTRA_SHORTCUT_NAME, title);
in.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(
BrowserBookmarksPage.this,
R.drawable.ic_launcher_shortcut_browser_bookmark));
in.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
//or in.setAction(Intent.ACTION_CREATE_SHORTCUT);
sendBroadcast(in);