美文网首页
Android通过报名启动app

Android通过报名启动app

作者: 阿布多12 | 来源:发表于2019-02-26 11:03 被阅读0次

    public void jumpToAppByPackage(final String packname) {

    runOnUiThread(new Runnable() {

    @Override

            public void run() {

    PackageManagerpackageManager = getPackageManager();

                if (checkPackInfo(packname)) {

    Intentintent =packageManager.getLaunchIntentForPackage(packname);

                    startActivity(intent);

                }else {

    Toast.makeText(MainActivity.this, getString(R.string.no_found_app) +packname, Toast.LENGTH_LONG).show();

                }

    }

    });

    }

    private boolean checkPackInfo(String packname) {

    PackageInfo packageInfo =null;

        try {

    packageInfo = getPackageManager().getPackageInfo(packname, 0);

        }catch (PackageManager.NameNotFoundException e) {

    e.printStackTrace();

        }

    return packageInfo !=null;

    }

    相关文章

      网友评论

          本文标题:Android通过报名启动app

          本文链接:https://www.haomeiwen.com/subject/rvzoyqtx.html