我可以仅使用网站中的包名称打开Android应用程序吗?

问题描述 投票:0回答:1

我想知道是否可以制作一个可以使用包名称启动任何应用程序(假设用户已安装)的按钮,我不认为有可能,但有人可能知道如何做。

document.location.href = 'intent:#Intent;scheme=app_scheme;package=app_package;end;';


只需转到显示 app_package 应用程序的 google play 应用程序

我尝试过一两件事,但没有其他有效的方法

javascript java android html package
1个回答
0
投票
是的,使用此代码

按钮 launchButton = findViewById(R.id.launchButton);

launchButton.setOnClickListener(new View.OnClickListener() { 公共无效onClick(查看视图){ String 包名 = "exampleapp"; // 替换为目标应用程序的包名

Intent launchIntent = getPackageManager().getLaunchIntentForPackage(packageName); if (launchIntent != null) { startActivity(launchIntent); } else { // Handle the case where the target app is not installed Toast.makeText(getApplicationContext(), "App not installed", Toast.LENGTH_SHORT).show(); } }
});

© www.soinside.com 2019 - 2024. All rights reserved.