小编Rhe*_*Bee的帖子

Chrome自定义标签 - 意图未被触发(Android)

我正在努力将PayPal应用到我当前的Android应用程序中,并且我被建议使用Chrome自定义标签,但我似乎无法触发Intent.

我相信我已经在AndroidManifest.xml中正确设置了Intent

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

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name=".CompletePayPalPaymentActivity">
            <intent-filter android:autoVerify="true">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data
                android:scheme="Test"
                android:host="com.Test.TestApp.PayPalReturn"/>
            </intent-filter>
        </activity>
    </application>
</manifest>
Run Code Online (Sandbox Code Playgroud)

我能够在Fragment类中成功启动Google Chrome Tabs(我有2个按钮:

  • 一个按钮,可在Chrome自定义标签中启动www.google.co.uk
  • 一个按钮,用于启动我的自定义网页(托管在localhost上),当用户单击按钮/链接时,该按钮将引发重定向

请看下面这段片段的代码:

public class MainFragment extends Fragment implements CustomTabsSceneHelper.ConnectionCallback {

    public enum CustomTabsAction {
        GOOGLE ("Open Google", "http://google.co.uk"),
        REDIRECT ("Open Redirect", "http://{mylocalhost_ip}/~Rhiannon/example1/test.html");

        private final String mActionDescription;
        private final String …
Run Code Online (Sandbox Code Playgroud)

android paypal android-intent url-redirection chrome-custom-tabs

4
推荐指数
1
解决办法
2081
查看次数