Example usage for android.content Context getApplicationContext

List of usage examples for android.content Context getApplicationContext

Introduction

In this page you can find the example usage for android.content Context getApplicationContext.

Prototype

public abstract Context getApplicationContext();

Source Link

Document

Return the context of the single, global Application object of the current process.

Usage

From source file:m2.android.archetype.sharedpref.BaseSharedPrefModel.java

public void setContext(Context context) {
    this.context = context.getApplicationContext();
}

From source file:kaist.cs492c_2015.washerbrowser.MyGcmListenerService.java

private void launchPopupActivity(Context context, String datavalue) {
    Intent pupInt = new Intent(context, ShowPopup.class);
    pupInt.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    pupInt.putExtra("customdata", datavalue);
    context.getApplicationContext().startActivity(pupInt);
}

From source file:com.nostra13.universalimageloader.core.download.BaseImageDownloader.java

public BaseImageDownloader(Context context, int connectTimeout, int readTimeout) {
    this.context = context.getApplicationContext();
    this.connectTimeout = connectTimeout;
    this.readTimeout = readTimeout;
}

From source file:com.ihelpoo.app.AppException.java

/**
 * ?APP//from www .j  a  va 2s.co  m
 * @param ex
 * @return
 */
private String getCrashReport(Context context, Throwable ex) {
    PackageInfo pinfo = ((AppContext) context.getApplicationContext()).getPackageInfo();
    StringBuffer exceptionStr = new StringBuffer();
    exceptionStr.append("Version: " + pinfo.versionName + "(" + pinfo.versionCode + ")\n");
    exceptionStr.append("Android: " + android.os.Build.VERSION.RELEASE + "(" + android.os.Build.MODEL + ")\n");
    exceptionStr.append("Exception: " + ex.getMessage() + "\n");
    StackTraceElement[] elements = ex.getStackTrace();
    for (int i = 0; i < elements.length; i++) {
        exceptionStr.append(elements[i].toString() + "\n");
    }
    return exceptionStr.toString();
}

From source file:mobisocial.musubi.ui.util.EmojiSpannableFactory.java

private EmojiSpannableFactory(Context context) {
    mContext = context.getApplicationContext();
    new PrepareEmojiAsyncTask().execute();
}

From source file:com.mobilesolutionworks.android.http.WorksHttpClient.java

/**
 * Constructor of http client/*  w  w w  .  j a v a 2  s. com*/
 *
 * @param context application context
 */
protected WorksHttpClient(Context context) {
    mContext = context.getApplicationContext();
    String name = mContext.getPackageName();

    try {
        PackageManager pm = mContext.getPackageManager();
        if (pm != null) {
            ApplicationInfo ai = pm.getApplicationInfo(mContext.getPackageName(), 128);
            if ((ai != null) && (ai.metaData != null)) {
                name = ai.metaData.getString("user_agent");
            }

            PackageInfo pi = pm.getPackageInfo(mContext.getPackageName(), 0);
            if (pi != null) {
                name = name + " ver-" + pi.versionName + " build-" + pi.versionCode;
            }
        }
    } catch (PackageManager.NameNotFoundException e) {
    }

    mName = name;
}

From source file:com.android.fastlibrary.AppException.java

/**
 * ?APP/*w w  w. j a  v  a2 s  .c o  m*/
 *
 * @param ex
 * @return
 */
private String getCrashReport(Context context, Throwable ex) {
    PackageInfo pinfo = ((BaseApplication) context.getApplicationContext()).getPackageInfo();
    StringBuffer exceptionStr = new StringBuffer();
    exceptionStr.append("Version: " + pinfo.versionName + "(" + pinfo.versionCode + ")\n");
    exceptionStr.append("Android: " + android.os.Build.VERSION.RELEASE + "(" + android.os.Build.MODEL + ")\n");
    exceptionStr.append("Exception: " + ex.getMessage() + "\n");
    StackTraceElement[] elements = ex.getStackTrace();
    for (int i = 0; i < elements.length; i++) {
        exceptionStr.append(elements[i].toString() + "\n");
    }
    return exceptionStr.toString();
}

From source file:at.tugraz.kmi.energy2live.remote.E2LNetworkConnection.java

public E2LNetworkConnection(Context context) {
    mContext = context;/*from www  .  j  a v  a  2s . c o  m*/
    mXstream = new XStream();
    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
    mCallbacks = new ArrayList<Callback>();
}

From source file:jahirfiquitiva.iconshowcase.services.NotificationsService.java

private Class getLauncherClass(Context context) {
    Class<?> className = null;

    String componentNameString = Utils.getAppPackageName(context.getApplicationContext()) + "."
            + Utils.getStringFromResources(context, R.string.main_activity_name);

    try {/*ww w . j a v  a  2s .c  o m*/
        className = Class.forName(componentNameString);
    } catch (ClassNotFoundException e) {
        try {
            componentNameString = Utils.getStringFromResources(context, R.string.main_activity_fullname);
            className = Class.forName(componentNameString);
        } catch (ClassNotFoundException e1) {
            //Do nothing
        }
    }

    return className;
}