What is the package name of the Android Market or Google Apps

后端 未结 2 1250
时光取名叫无心
时光取名叫无心 2020-12-17 21:15

I need to check if the Android Market is installed like this

    /*
     * Test for existence of Android Market
     */
    boolean androidMarketExists = fal         


        
2条回答
  •  爱一瞬间的悲伤
    2020-12-17 21:57

    Your code is right just needs minor changes

    Check out code modified below:

    boolean androidMarketExists = false;
        try{
            ApplicationInfo info = getPackageManager().getApplicationInfo("com.android.vending", 0 );
            if(info.packageName.equals("com.android.vending"))
                androidMarketExists = true;
            else
                androidMarketExists = false;
        } catch(PackageManager.NameNotFoundException e ){
            //application doesn't exist
            androidMarketExists = false;
        }
        if(!androidMarketExists){
            Log.d(LOG_TAG, "No Android Market");
            finish();
        }
        else{
            Log.d(LOG_TAG, "Android Market Installed");
        }
    

提交回复
热议问题