Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.app.Activity;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

public class Main {
    public static boolean isZhihuInstalled(Activity activity) {
        PackageInfo packageInfo;
        try {
            packageInfo = activity.getPackageManager().getPackageInfo("com.zhihu.android", 0);
        } catch (PackageManager.NameNotFoundException e) {
            packageInfo = null;
            e.printStackTrace();
        }

        return (packageInfo == null) ? false : true;
    }
}