【问题标题】:create html link that open an android application创建打开 android 应用程序的 html 链接
【发布时间】:2023-04-06 04:51:01
【问题描述】:

我想在我的移动网站上创建一个简单的 html href 链接,该链接将打开一个 android 应用程序,如 waze、whatsapp 或 viber。有没有办法做到这一点?

【问题讨论】:

标签: android html


【解决方案1】:

用于启动 Vkontakte 应用程序并打开我使用的个人资料页面:

if (isVKAppInstalled(context)) {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("vkontakte://profile/%d", vkUserId)));
            context.startActivity(intent);
        }

以及检查应用是否安装的方法:

public static boolean isVKAppInstalled(Context context) {
        PackageManager pm = context.getPackageManager();
        boolean isInstalled;
        try {
            pm.getPackageInfo(VK_PACKAGE_URI, PackageManager.GET_ACTIVITIES);
            isInstalled = true;
        } catch (PackageManager.NameNotFoundException e) {
            isInstalled = false;
        }
        return isInstalled;
    }

【讨论】:

    猜你喜欢
    • 2023-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多