web链接跳转安卓app的问题

来源:互联网 发布:数据库应用领域 编辑:程序博客网 时间:2024/05/16 07:32

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.

0 0
原创粉丝点击