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

import android.provider.MediaStore;

public class Main {
    /**
     * Returns true if the device has a camera application installed, false
     * otherwise.
     */
    public static boolean hasCameraApplication(Context ctx) {
        return isIntentAvailable(ctx, MediaStore.ACTION_IMAGE_CAPTURE);
    }

    /**
     * Returns true if the intent action is available on the device, false
     * otherwise.
     */
    public static boolean isIntentAvailable(Context ctx, String action) {
        PackageManager pm = ctx.getPackageManager();
        Intent intent = new Intent(action);
        return pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY).size() > 0;
    }
}