【问题标题】:How to link to from one Android app to another? [duplicate]如何从一个 Android 应用链接到另一个? [复制]
【发布时间】:2017-05-27 05:44:52
【问题描述】:

Google 有一个不错的页面显示如何执行此操作: https://developer.android.com/distribute/tools/promote/linking.html

基本上,使用此代码,它将打开 Play 商店到新应用页面:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.example.android"));
startActivity(intent);

但是当我尝试这个时,我得到了错误:

 Cannot resolve the symbol 'Uri'

我错过了什么?我敢肯定它非常简单,也许我需要导入一些东西。

已解决:导入 Uri 类是问题所在。我仍然不确定导入它的新热键是什么。 Apple-Shift-o 不再起作用。过了一会儿,线路上的一个按钮出现了,并提出为我导入它。

【问题讨论】:

  • 请在询问之前做一些研究。 stackoverflow.com/questions/11753000/…
  • 我认为你应该重新表述你的问题——据我了解,这不是重复的,因为你知道它应该如何工作——这是关于你得到的错误。我想这是一个运行时错误,对吧?如果是编译器错误,您只需导入 Uri 类。

标签: java android


【解决方案1】:

使用正确的格式:

Intent intent = new Intent(Intent.ACTION_VIEW);
Uri.parse("market://details?id=com.example.android"));
startActivity(intent);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-26
    • 2020-04-23
    • 1970-01-01
    • 1970-01-01
    • 2021-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多