Airbnb DeepLinkDispatch无法路由深层链接

时间:2017-05-03 18:26:13

标签: android deep-linking

我正在尝试在我的Android应用程序中使用Airbnb DeepLinkDispatch库来处理深层链接,但我无法使其正常工作。

我创造了这个词:

AppDeepLinkModule.java

@DeepLinkModule
public class AppDeepLinkModule {
}

DeepLinkDispatchActivity.java

@DeepLinkHandler({AppDeepLinkModule.class})
public class DeepLinkDispatchActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // DeepLinkDelegate, LibraryDeepLinkModuleLoader and AppDeepLinkModuleLoader
        // are generated at compile-time.
        DeepLinkDelegate deepLinkDelegate =
                new DeepLinkDelegate(new AppDeepLinkModuleLoader());
        // Delegate the deep link handling to DeepLinkDispatch.
        // It will start the correct Activity based on the incoming Intent URI
        deepLinkDelegate.dispatchFrom(this);
        // Finish this Activity since the correct one has been just started
        finish();
    }

}

TestDeepLinkActivity.java

公共类TestDeepLinkActivity扩展了Activity {

private static final String TAG = TestDeepLinkActivity.class.getSimpleName();

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

@DeepLink("myapp://users")
public static Intent intentForUsers(Context context) {
    Intent i = new Intent();
    i.setAction(BuildConfig.APPLICATION_ID + "." + "MY_ACTION");
    return i;
}

然后我在AndroidManifest.xml中添加了这个:

<activity
    android:name=".common.DeepLinkDispatchActivity"
    android:theme="@android:style/Theme.NoDisplay">
    <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:scheme="myapp"/>
        <data android:scheme="myApp"/>
    </intent-filter>
</activity>

当我点击网页中的链接时,它正在输入DeepLinkDispatchActivity的onCreate方法,但它没有调度 intentForUsers方法。

为了使这个lib工作,我有什么东西可以配置吗?

0 个答案:

没有答案