从Android应用程序创建主屏幕浏览器快捷方式

我有一个php网站,它基本上就像一个网站目录,我想要实现的是从我点击应用程序中的URL时创建主屏幕快捷方式,这意味着:我需要先拦截url,解码它,并在url中创建一个参数的浏览器快捷方式。

非常感谢,Itai。

制作快捷方式很容易

final Intent i = new Intent(); //intent for the shortcut final Intent shortcutIntent = new Intent( /*put necessary parameters (ie activity to launch)*/ ); shortcutIntent.putExtra(Browser.EXTRA_APPLICATION_ID /*if your launching a browser*/, Long.toString(/*put unique id eg system time etc.*/)); i.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); i.putExtra(Intent.EXTRA_SHORTCUT_NAME, /*title*/); i.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,/*drawable*/); i.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); sendBroadcast(i); 

用于URL拦截,在WebViewClient中

 @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.equalsIgnoreCase(/*your sitemap url*/)) { //use the above code } return true; } 

我希望这有帮助。 我没有测试过这个,但这是一般的想法! 祝好运