Intent.action.VIEW在某些设备上不起作用 [英] Intent.action.VIEW does not work on some devices

查看:128
本文介绍了Intent.action.VIEW在某些设备上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在电子邮件,消息或浏览器应用程序中单击URL链接时,我需要打开我的应用程序.因此,请参见此功能的代码:

I need to open my application when clicked the URL Link in E-mail, Message or Browser applications. So, see the my code for this feature:

<activity
    android:name=".ui.main.MainActivity"
    android:configChanges="orientation"
    android:screenOrientation="portrait">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

    <intent-filter>
        <data android:scheme="https" />
        <data android:scheme="https" android:host="www.mysite.org"/>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <category android:name="android.intent.category.APP_EMAIL"/>
        <category android:name="android.intent.category.APP_MESSAGING"/>
        <category android:name="android.intent.category.APP_BROWSER"/>
        <category android:name="android.intent.category.DEFAULT"/>
    </intent-filter>
</activity>

此代码已足够,并且可以在某些移动设备上使用,尤其是在Android版本为 5.0、6.0和7.0 的设备上,但在版本 7.1和8.0 上不能使用.为什么会这样?是权限问题吗?

This code is sufficient and works on some mobile devices, especially devices with android versions 5.0, 6.0 and 7.0 but does not work on versions 7.1 and 8.0. Why does this happen? Is it a permission problem?

推荐答案

例如:您的网址类似于 https://example.com ,您将在Android Manifest中使用如下意图过滤器:

Ex: Your url will be something like https://example.com and you have the intent filter in Android Manifest as below:

<activity
    android:name="com.droid.MainActivity"
    android:label="@string/app_name" >

    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data
            android:host="example.com"
            android:scheme="https" />
    </intent-filter>
</activity>

使用 URL映射编辑器可通过Android应用链接(Android Studio>工具> Android应用链接)轻松将URL目的过滤器添加到您的活动中.

Use the URL Mapping editor to easily add URL intent filters to your Activities with Android App Links (Android Studio > Tools > Android App Links).

这篇关于Intent.action.VIEW在某些设备上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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