从创建Android应用程序主屏幕上浏览器快捷方式 [英] Creating home screen browser shortcuts from android app

查看:164
本文介绍了从创建Android应用程序主屏幕上浏览器快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PHP的网站,这基本上就像一个网站目录,我想实现的是建立一个从当我点击的URL中的应用程序,这意味着主屏幕快捷方式: 我需要首先,拦截的URL,德code,然后创建一个浏览器快捷方式,在URL中的参数。

I have a php site, which is basically like a site directory, what I want to achieve is to create a home screen shortcuts from when I click a URL in an application, meaning: I need to first, intercept the url, decode it, and create a browser shortcut to a parameter within the url.

在此先感谢,板井。

推荐答案

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

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

这篇关于从创建Android应用程序主屏幕上浏览器快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆