I believe that many applications now support third-party login and will call third-party interface for authorization. Last week, I took over the same applications, using third-party login. In an accident, the company did not install QQ on the test machine. I clicked on third-party authorized login and never responded. I thought I had code problems and after some testing, the test machine did not install QQ, so IA tool class has been written to detect whether the machine has these applications installed.The code below is for reference only.
/** * Created by zhou on 2018/7/23. * Detection Tool Class to detect if these apps are installed on your phone * Drop the appropriate method when needed */ public class JudgeApplicationIsExistUtils { /** * Judging WeChat */ public static boolean isWeixinAvilible(Context context) { final PackageManager packageManager = context.getPackageManager();// Get packagemanager List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);// Get package information for all installed programs if (pinfo != null) { for (int i = 0; i < pinfo.size(); i++) { String pn = pinfo.get(i).packageName; if (pn.equals("com.tencent.mm")) { return true; } } } return false; } /** * Determine if qq is available */ public static boolean isQQClientAvailable(Context context) { final PackageManager packageManager = context.getPackageManager(); List<PackageInfo> pinfo = packageManager.getInstalledPackages(0); if (pinfo != null) { for (int i = 0; i < pinfo.size(); i++) { String pn = pinfo.get(i).packageName; if (pn.equals("com.tencent.mobileqq")) { return true; } } } return false; } /** * Judging Weibo */ public static boolean isWeiboIAvilible(Context context) { PackageManager pm; if ((pm = context.getApplicationContext().getPackageManager()) == null) { return false; } List<PackageInfo> packages = pm.getInstalledPackages(0); for (PackageInfo info : packages) { String name = info.packageName.toLowerCase(Locale.ENGLISH); if ("com.sina.weibo".equals(name)) { return true; } } return false; } }
The three methods above are to check if the application is installed, using the following
if (JudgeApplicationIsExistUtils.isQQClientAvailable(LoginActivity.this)){ // Already installed to do what you want to do, no threading prompt }else { Toast.makeText(LoginActivity.this,"It was detected that you are not installed or logged on QQ!",Toast.LENGTH_SHORT).show(); }