Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.app.Activity;

import android.content.Context;
import android.content.Intent;

import android.provider.MediaStore;

public class Main {

    public static void chooserSysPics(Context context, int requestCode) {
        if (context == null) {
            return;
        }

        try {
            Intent localIntent = new Intent();
            localIntent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            localIntent.setType("image/*");
            // Intent.ACTION_GET_CONTENT
            localIntent.setAction("android.intent.action.GET_CONTENT");
            if (context instanceof Activity) {
                ((Activity) context).startActivityForResult(localIntent, requestCode);
            } else {
                localIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(localIntent);
            }
        } catch (Exception e) {
        }
    }
}