dee*_*kar 8 browser android location google-chrome web
我正在尝试使用Android Intents点击按钮,从Chrome(在Android上)打开位置设置.我正在关注条码扫描器示例并尝试以类似的方式对网址进行编码.对于位置,我试过这个: -
const uri = "intent://com.google.android.gms.location.settings.GOOGLE_LOCATION_SETTINGS#Intent;action=com.google.android.gms.location.settings.GOOGLE_LOCATION_SETTINGS;end"
Run Code Online (Sandbox Code Playgroud)
我也尝试用这个打开设置: -
const uri = "intent://ACTION_SETTINGS#Intent;action=android.provider.Settings.ACTION_SETTINGS;end"
Run Code Online (Sandbox Code Playgroud)
或这个
const uri = "intent://android.provider.Settings.ACTION_SETTINGS#Intent;action=android.provider.Settings.ACTION_SETTINGS;end"
Run Code Online (Sandbox Code Playgroud)
但似乎没有任何效果.任何帮助表示赞赏.
我使用href标签将它附加到一个按钮.
好像你不能打开直接从Android的意图与Chrome的位置设置,因为设置活动不支持BROWSABLE
类(详细看看这个的问题Dickeylth和答案的拉法尔·马利克)。但是您可以 100% 通过自定义 android 应用程序和带有支持的自定义活动的深层链接来做到这一点<category android:name="android.intent.category.BROWSABLE"/>
,就像在那个教程中一样。
在这种情况下,您的应用程序SettingsActivity
代码应如下所示:
public class SettingsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startActivityForResult(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0);
}
}
Run Code Online (Sandbox Code Playgroud)
和AndroidManifest.xml
部分SettingsActivity
<activity android:name=".SettingsActivity">
<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:host="open.location.settings"
android:scheme="http"/>
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
最后,SettingsActivity
HTML 文件中的“深层”链接:
<a href="http://open.location.settings">Open Location Settings</a>
Run Code Online (Sandbox Code Playgroud)
似乎,如果您不想在用户端安装应用程序,您也可以在Instant Apps 中执行此操作。您可以在此处找到有关 Instant App 链接的详细信息。
归档时间: |
|
查看次数: |
1666 次 |
最近记录: |