Android简单判断某个APK是否安装的方法

利用 PackageManager 类的方法 getPackageInfo来判断,,分享给大家供大家参考

private boolean isAppInstalled(String uri){

PackageManager pm = getPackageManager();

boolean installed =false;

try{

pm.getPackageInfo(uri,PackageManager.GET_ACTIVITIES);

installed =true;

}catch(PackageManager.NameNotFoundException e){

installed =false;

}

return installed;

}

 

上面是写好的方法,只要再call下就行

if(isAppInstalled("com.yourpackage.package")){

//app installed

}

else{

//app not installed

}

你可能感兴趣的:(Android,方法)