0
我正在写一个浏览器,并希望实现一个按钮“添加网站到主屏幕”,以便网站图标(apple-touch-icon)和标题可以通过启动器获取并显示。Android将图标添加到主屏幕(启动器)
我发现这确实是代码 -
Intent shortcutIntent = new Intent();
shortcutIntent.setClassName(getPackageName(), "Browser");
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
shortcutIntent.addCategory(Intent.ACTION_PICK_ACTIVITY);
shortcutIntent.putExtra("EXTRA_URL", webView.getUrl());
Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, webView.getTitle());
intent.putExtra(Intent.EXTRA_ORIGINATING_URI, webView.getUrl());
//TODO change to apple-touch icon
Bitmap btm = webView.getFaviconImage();
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, btm);
intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
sendBroadcast(intent);
但不幸的是,意图在的onCreate是没有任何额外的数据:
if (getIntent() != null){
Intent intent = getIntent();
//empty
String url1 = intent.getStringExtra("EXTRA_URL");
}
我应该如何通过额外parametr(URL)到发射器,以便进一步我可以读取它?
不工作,仍然没有数据到达帐篷 –