【问题标题】:android custom scheme and chrome intentandroid自定义方案和chrome意图
【发布时间】:2014-07-01 00:17:37
【问题描述】:

我有一个用 Xamarin 开发的跨平台应用程序。在 iOS 版本中,我使用自定义 url 方案在 web 视图中加载特定网页,例如

myapp://?returnUrl=http:/google.com.au

由于客户几乎没有我们提供的其他应用程序,因此他希望将自定义方案保持相同的格式。在 android 中,我发现可以从 Firefox 打开这样的意图,但不能从电子邮件或 Chrome 中打开。我发现Chrome needs a custom intent to make it work。我试图实现它,但无法实现。

这是我的清单实现:

[Activity(Label = "MyApp",
    MainLauncher = true,
    LaunchMode = LaunchMode.SingleTask,
    ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize)]
[IntentFilter(new[] { Intent.ActionView },
    Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
    DataScheme = "myapp")]

wich 将创建以下清单文件:

<activity android:configChanges="orientation|screenSize" android:label="MyApp" android:launchMode="singleTask" android:name="myapp.auth.droid.MainActivity">
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
  <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" />
  </intent-filter>
</activity>

我尝试从 Firefox 捕获意图并将其转换为应用程序中的 URI,但以下意图在 Chrome 中不起作用(它在 Firefox BTW 中起作用):

myapp://?returnUrl=http:/google.com.au#Intent;action=android.intent.action.VIEW;launchFlags=0x4400000;component=MyApp.MyApp/myapp.auth.droid.MainActivity;end

我错过了什么吗?

注意。可以使用 http:// 方案,但不是首选方案。

注意 2。我使用的是 Nexus 5,Android 4.4.4

【问题讨论】:

  • 你能放一个虚拟主机吗,或者只是一个额外的斜线,myapp://dummy/?returnUrl...

标签: android google-chrome android-intent xamarin


【解决方案1】:

对于chrome,需要使用chrome Intent,18以后的版本不再支持旧方式

意图应该看起来像这种格式的东西

intent://some_optional_data#Intent;scheme=app_scheme;package=package_name;end

查看此网站了解更多详细信息:Android Intents with Chrome

此方法也将回退到 google play

【讨论】:

  • 我显然可以在 Chrome 36.0.1985.131 中使用旧方法。
  • 这个答案没用。它没有解释 url 的组成部分。 Android Intents with Chrome 也是一个糟糕的文档。
  • 你有更好的吗? @caleb
  • 它在 2019 年有效吗?请详细解释答案。
猜你喜欢
  • 1970-01-01
  • 2016-01-30
  • 2011-04-30
  • 2011-12-14
  • 1970-01-01
  • 2016-08-28
  • 2016-12-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多