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

后端 未结 4 1930
滥情空心
滥情空心 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:40

    use below code

    String packageName = "app_package_name";
    Intent intent = getPackageManager().getLaunchIntentForPackage(packageName);
    
    if(intent == null) {
       intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+packageName));
    }
      startActivity(intent);
    

提交回复
热议问题