简体   繁体   English

URL方案(imdb:///,linkedin://)无法在Android设备中启动应用

[英]URL Scheme (imdb:///, linkedin://) not launching app in Android device

I have tested this scheme URL ( imdb:/// , linkedin:// ) app home page can't launching in Android device. 我已经测试了该方案URL( imdb:///linkedin:// )应用程序首页无法在Android设备中启动。 but both home page/specified page app scheme URL works fine in iOS. 但是首页/指定页面应用方案网址都可以在iOS中正常运行。

( imdb:///title/tt1931435/ , linkedin://profile/{id} ) this specified app page launch perfectly in Android device. imdb:///title/tt1931435/linkedin://profile/{id} ),此指定的应用页面可在Android设备中完美启动。

I can't understand why this different in scheme URL? 我不明白为什么方案网址与此不同?

Appreciate your inputs on how to resolve this 感谢您对如何解决此问题的投入

In iOS you directly register your app to open for scheme's. 在iOS中,您可以直接注册您的应用以打开方案。 When you do that, whatever you give after imdb://, the app opens. 当您执行此操作时,无论在imdb://之后给出什么,应用程序都会打开。 You can open it with either imdb:// or imdb://something 您可以使用imdb://或imdb:// something打开它

But in Android the behavior is different. 但是在Android中,行为有所不同。 You don't simply register for the scheme, you register for the complete path or path prefix or even use regex. 您不仅可以注册该方案,还可以注册完整的路径或路径前缀,甚至可以使用正则表达式。 When imdb:///title/tt1931435/ opens the IMDB app, simple imdb:// may not open the app directly. 当imdb:/// title / tt1931435 /打开IMDB应用程序时,简单的imdb://可能不会直接打开该应用程序。

The developers behind IMDB app probably wanted the app to be open only from the movie screens but not from the main screen. IMDB应用程序背后的开发人员可能希望仅从电影屏幕打开应用程序,而不能从主屏幕打开。

Edit: After your comment I looked up AndroidManifest.xml files of both Facebook and IMDB and the result is the below 编辑:在您发表评论后,我查找了Facebook和IMDB的AndroidManifest.xml文件,结果如下

IntentFilter in IMDB application: IMDB应用程序中的IntentFilter:

        <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="imdb" android:host="" android:pathPattern="/title/tt.*" />
        </intent-filter>

IntentFilter in Facebook application: Facebook应用程序中的IntentFilter:

        <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="fb" />
        </intent-filter>

In Facebook, there is only "fb" and this means all the url's that starts with fb:// will open the app. 在Facebook中,只有“ fb”,这意味着以fb://开头的所有URL都将打开该应用程序。 But in IMDB, they provided android:pathPattern , which means only the URL's that fit that pattern will open the app. 但是在IMDB中,他们提供了android:pathPattern ,这意味着只有适合该模式的URL才能打开应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM