意图过滤器不能作为我的表达

时间:2018-06-15 08:11:34

标签: android android-intent

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.desk.rnd">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name=".ShowActivity">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="http" />
                <data android:scheme="https" />
            </intent-filter>
        </activity>
    </application>

</manifest>

以上xml是我的完整Manifest.xml代码。

我正在使用三星S4,Note8,Momo Emulator作为测试手机。

在某些浏览器中共享网页时,我无法获取网址。

测试浏览器:Yandex,三星默认,Chrome。

如果操作是SEND并删除类别中的BROWABLE,我可以在共享窗口中显示我的应用程序。

但这不是我想要的。

如何从链接共享中获取网址?

[解决]

<activity android:name=".ShowActivity">
    <intent-filter>
        <action android:name="android.intent.action.SEND" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="text/plain" />
    </intent-filter>
</activity>

0 个答案:

没有答案