【问题标题】:how to open link with app instead of browser如何用应用程序而不是浏览器打开链接
【发布时间】:2018-07-27 22:28:45
【问题描述】:

我正在尝试读取条码,然后从该条码获取 URL,然后尝试打开该 URL。它显示这个页面是 open with appcontinue with browser 。即使选择 open with app 。下次它会问我这个页面。怎么用 Autocad a360 app 直接打开这个 url。

这是我的代码:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(StringURL));
startActivity(intent);

【问题讨论】:

  • 如果我理解正确,您不想在自己的应用程序中打开此 URL,而是在该设备上安装的另一个应用程序中打开。这不是您可以从您的应用程序中执行的任何操作,因为它发生在操作系统级别。根据您的 Android 版本,应该可以定义默认应用程序。但当然,其他应用程序必须支持打开该 URL(就是这种情况,否则它不会在打开方式对话框中列出)

标签: android android-intent


【解决方案1】:

将此代码添加到清单。

<activity
 android:theme="@style/AppTheme.Launcher"
 android:name=".features.MainActivity">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    <intent-filter android:label="@string/app_name">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:host="YOURSITE.com"
              android:scheme="http" />
    </intent-filter>
</activity>

当您尝试打开http://YOURSITE.com 时,应用程序将启动 深层链接是正确答案

【讨论】:

    猜你喜欢
    • 2020-10-25
    • 1970-01-01
    • 2019-04-05
    • 2012-07-01
    • 2016-06-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-10
    相关资源
    最近更新 更多