您的位置:首页 > 移动开发

web链接跳转安卓app的问题

2014-10-14 11:36 330 查看


Load a web URL





Google Now

"open example.com"

To open a web page, use the
ACTION_VIEW
action
and specify the web URL in the intent data.

Action
ACTION_VIEW
Data URI Scheme
http:<URL>


https:<URL>
MIME Type
PLAIN_TEXT_TYPE
(
"text/plain"
)
"text/html"
"application/xhtml+xml"
"application/vnd.wap.xhtml+xml"


Example intent:
public void openWebPage(String url) {
Uri webpage = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, webpage);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}


Example intent filter:
<activity ...>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<!-- Include the host attribute if you want your app to respond
only to URLs with your app's domain. -->
<data android:scheme="http" android:host="www.example.com" />
<category android:name="android.intent.category.DEFAULT" />
<!-- The BROWSABLE category is required to get links from web pages. -->
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>


Tip: If your Android app provides functionality similar to your web site, include an intent filter for URLs that point to your web site. Then, if users have your app installed, links from emails or other web pages pointing to your web site
open your Android app instead of your web page.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: