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.content.Context;
import android.content.pm.PackageManager;

import android.os.Build;

public class Main {
    public static boolean hasCamera(Context context) {
        if (context == null || context.getPackageManager() == null) {
            throw new IllegalArgumentException("Context and package manager must not be null");
        }
        PackageManager pm = context.getPackageManager();
        if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
            return true;
        } else if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
            return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT);
        } else {
            return false;
        }
    }
}