how to open android application if installed and go to android market if not install

后端 未结 4 1936
滥情空心
滥情空心 2020-12-30 02:48

I would like to make android button and able to launch other application if already installed and go to android market if not yet installed.

How to do this?

4条回答
  •  清歌不尽
    2020-12-30 03:41

    inside onclick

    @Override
    public void onClick(View view){
      try{
        startActivity(getPackageManager().getLaunchIntentForPackage("applicationId"));
      } catch (PackageManager.NameNotFoundException e) {
        startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse("https://play.google.com/store/apps/details?id=" + "applicationId")));
     }
    }
    

提交回复
热议问题