I am writing a browser, and want implement a button "add site to home screen" so the site icon (apple-touch-icon) and title would be fetched by launcher and displayed.
I have found the code which does that -
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);
But, unfortunately, intent in onCreate is without any extra data :
if (getIntent() != null){
Intent intent = getIntent();
//empty
String url1 = intent.getStringExtra("EXTRA_URL");
}
How should I pass extra parametr (URL), to launcher so that further i could read it ?