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;

public class Main {
    private static Context sCurrentContext;

    /**
     * <pre>
     * Check if android:debuggable is set to true
     * </pre>
     */
    public static boolean getAppFlagDebug() {
        ApplicationInfo appInfo = getCurrentContext().getApplicationInfo();
        int appFlags = appInfo.flags;
        boolean b = (appFlags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
        return b;
    }

    /**
     * <pre>
     * Get current context of the app. This method resolves the inconvenience of Android which requires context for most of its API.
     * If no activity is resumed, this method returns application context. Otherwise, this method returns last resumed activity.
     * </pre>
     */
    public static Context getCurrentContext() {
        return sCurrentContext;
    }
}