Android 安卓从url启动活动不需要';不能在浏览器中工作,但可以在文本编辑器中工作
当用户从浏览器中单击URL时,我想启动我的Android 安卓从url启动活动不需要';不能在浏览器中工作,但可以在文本编辑器中工作,android,Android,当用户从浏览器中单击URL时,我想启动我的活动。我通过以下方式创建自定义清单: <activity android:name=".views.RestorePwActivity" android:screenOrientation="portrait" android:windowSoftInputMode="stateHidden|adjustResize" android:exported="true"&g
活动。我通过以下方式创建自定义清单:
<activity
android:name=".views.RestorePwActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize"
android:exported="true">
<intent-filter>
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.VIEW" />
<data
android:host="mysite.com"
android:scheme="https" />
</intent-filter>
</activity>
Activity
在notes或任何文本编辑器中单击URL
时打开,但在浏览器中单击URL
时,它会将我重定向到网站
我在堆栈溢出上看到了类似的问题,但这些答案都没有帮助。
我还读到一些观点,认为现代浏览器限制了这种行为。我使用的是安卓5+。有可能做到这一点吗?深度链接请参考Android原始文档
因为你的代码在清单中看起来很好,但我不能编译它。如果需要代码帮助,请共享您的项目
我希望给出的链接将有帮助 深度链接示例代码:
舱单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="splus.in.codestructure">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".HomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
<data android:scheme="example"
android:host="deeplinksample" />
<!-- note that the leading "/" is required for pathPrefix-->
</intent-filter>
</activity>
</application>
</manifest>
您可以通过两种方式执行:
命令行:
F:\AndroidStudioSetup\sdk\platform-tools> adb shell am start -W -a android.intent.action.VIEW -d "example://deeplinksample" splus.in.codestructure
控制台上的输出:
Starting: Intent { act=android.intent.action.VIEW dat=example://deeplinksample pkg=splus.in.codestructure }
Status: ok
Activity: splus.in.codestructure/.HomeActivity
ThisTime: 90
TotalTime: 10383
WaitTime: 108
Complete
如果要从浏览器打开,请尝试以下代码:
Deeplinking.html
您可以将此文件保存在服务器上,也可以复制到SD卡上并用浏览器打开,然后单击**深链接示例。它将打开你的应用程序
如果需要更多帮助,请告诉我 嗨!谢谢你的回答。因此,1。我做了和你之前建议的一样的事情,当我运行adb命令时,我看到我的应用程序有一个对话框,没关系。2.当我在浏览器中单击URL时,对话框不会出现,它会将我重定向到网站。3.我将方案从https改为示例,效果很好!太棒了!但我需要通过单击https方案打开我的应用程序。你知道为什么https方案不起作用吗?我试过使用数据&当我运行html页面时,它起作用了。它要求我用浏览器/我们的应用程序等打开。我将意图过滤器配置为:不起作用。
Starting: Intent { act=android.intent.action.VIEW dat=example://deeplinksample pkg=splus.in.codestructure }
Status: ok
Activity: splus.in.codestructure/.HomeActivity
ThisTime: 90
TotalTime: 10383
WaitTime: 108
Complete