android - Android 中的 iOS OpenUrl 等效项

标签 android ios browser openurl

有没有办法在android中实现OpenUrl功能(如iOS OpenUrl)?

例如, 如果用户从网页(在浏览器中)重定向到“myapp://main”, android 将启动我的应用程序。

最佳答案

答案只是将其添加到您要启动的 Activity 中的 list 中:

<activity
    android:name="com.dimrix.something.BootActivity"
    android:label="@string/app_name"
    android:screenOrientation="portrait" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>


         <intent-filter>
            <data android:scheme="SomeScheme" />
            <data android:scheme="otherScheme" />
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
         </intent-filter>


    </activity>

并且比在浏览器内编写

一些方案://

其他方案://

它将开始 Activity ......

如果您想通过获取 Activity 中的 Intent 数据来根据 url 执行操作,您甚至可以在方案之后发送信息

Uri data = getIntent().getData();

这样你就可以写

SomeScheme://水

并用 Uri 数据响应“水”。

关于android - Android 中的 iOS OpenUrl 等效项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23763781/

相关文章:

ios - 在图像上快速绘制图像 Assets

javascript - 当浏览器导航到文件下载时如何显示页面内容?

ios - 如何从两个 nsarrays 创建自定义 nsdictionary

ios - iOS 推送通知的 AWS SNS 声音未发生

Java JWebbrowser DocumentCompleted 事件

javascript - 更新数据库表并在浏览器关闭时终止 session

android - 我应该使用线程还是服务在 Android 的后台运行任务?

android - 通过 Android 中的 Activity 传递整数和字符串?

android - INSTALL_FAILED_UPDATE_INCOMPATIBLE 从 Play 商店版本更新到 Android Studio 的新版本

android - 需要数据连接才能连接到 Google Play 服务