且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2022-12-29 23:33:07

这是很容易做的快捷方式,

It's quite easy to make the shortcut,

final Intent i = new Intent(); //intent for the shortcut
final Intent shortcutIntent = new Intent( /*put necessary parameters (i.e activity to launch)*/ );
shortcutIntent.putExtra(Browser.EXTRA_APPLICATION_ID /*if your launching a browser*/,
        Long.toString(/*put unique id e.g. 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

for url interception, in a WebViewClient

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

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

I hope this helps. I have not tested this but this is the general idea! Good luck