Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.content.Context;

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

import android.util.Log;

public class Main {
    public static boolean isDebug(Context context) {
        boolean ret = false;
        if (context == null)
            return false;
        PackageManager manager = context.getPackageManager();
        try {
            PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
            int flag = info.applicationInfo.flags;
            if ((flag & ApplicationInfo.FLAG_DEBUGGABLE) == ApplicationInfo.FLAG_DEBUGGABLE) {
                ret = true;
            }
        } catch (NameNotFoundException e) {
            // TODO Auto-generated catch block
            Log.e("WxException", e.getMessage(), e);
        } catch (Throwable e) {
            // TODO: handle exception
            return false;
        }
        return ret;
    }
}