Example usage for android.app Activity getApplicationContext

List of usage examples for android.app Activity getApplicationContext

Introduction

In this page you can find the example usage for android.app Activity getApplicationContext.

Prototype

@Override
    public Context getApplicationContext() 

Source Link

Usage

From source file:com.sentaroh.android.TextFileBrowser.ViewedFileListAdapter.java

public ViewedFileListAdapter(Activity a, int resourceId, ArrayList<ViewedFileListItem> objects) {
    super(a, resourceId, objects);
    mActivity = a;//from   w w  w .ja va  2 s  .  c om
    mContext = a.getApplicationContext();
    mResourceId = resourceId;
    mFileViewList = objects;
}

From source file:samson.AndroidNotifications.java

/**
 * Constructs a new AndroidNotifications with the main activity to be launched when a
 * notification is tapped.//from   w  ww  . j av a  2 s  . c o m
 */
public AndroidNotifications(Activity mainActivity) {
    this.activityClass = mainActivity.getClass();
    this.applicationContext = mainActivity.getApplicationContext();
    this.notificationManager = (NotificationManager) applicationContext
            .getSystemService(Context.NOTIFICATION_SERVICE);
    this.alarmManager = (AlarmManager) applicationContext.getSystemService(Context.ALARM_SERVICE);
}

From source file:com.zbrown.droidsteal.activities.UpdateChecker.java

/**
 * Instantiates the update checker/*from ww  w . j av  a2  s.c  o  m*/
 *
 * @param c            The activity to be used for displaying the messages
 * @param versionUrl   The url of the file containing the version name
 * @param remoteApkUrl The url of the apk
 * @param alertIcon    The icon to show in the dialog, usually the application icon
 */
public UpdateChecker(Activity c, String versionUrl, String remoteApkUrl, int alertIcon) {
    this.activity = c;
    this.context = c.getApplicationContext();
    this.versionUrl = versionUrl;
    this.remoteApkUrl = remoteApkUrl;
    this.alertIcon = alertIcon;
    mHandler = new Handler();
}

From source file:com.apptentive.android.sdk.module.messagecenter.ApptentiveMessageCenter.java

public static void clearPendingMessageCenterPushNotification(Activity activity) {
    SharedPreferences prefs = activity.getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE);
    String pushData = prefs.getString(Constants.PREF_KEY_PENDING_PUSH_NOTIFICATION, null);
    if (pushData != null) {
        try {//  w w  w.  j  a v a 2  s  .co  m
            JSONObject pushJson = new JSONObject(pushData);
            ApptentiveInternal.PushAction action = ApptentiveInternal.PushAction.unknown;
            if (pushJson.has(ApptentiveInternal.PUSH_ACTION)) {
                action = ApptentiveInternal.PushAction
                        .parse(pushJson.getString(ApptentiveInternal.PUSH_ACTION));
            }
            switch (action) {
            case pmc:
                Log.i("Clearing pending Message Center push notification.");
                prefs.edit().remove(Constants.PREF_KEY_PENDING_PUSH_NOTIFICATION).commit();
                break;
            }
        } catch (JSONException e) {
            Log.w("Error parsing JSON from push notification.", e);
            MetricModule.sendError(activity.getApplicationContext(), e, "Parsing Push notification", pushData);
        }
    }
}

From source file:com.google.samples.apps.topeka.adapter.CategoryAdapter.java

public CategoryAdapter(Activity activity) {
    mActivity = activity;/*  ww w.  j  a  v a2s  . c o  m*/
    mResources = mActivity.getResources();
    mPackageName = mActivity.getPackageName();
    mLayoutInflater = LayoutInflater.from(activity.getApplicationContext());
    updateCategories(activity);
}

From source file:uk.org.rivernile.edinburghbustracker.android.fragments.general.AddProximityAlertFragment.java

/**
 * {@inheritDoc}//from  w w w. j a  v a2s  .  c o m
 */
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Bundle args = getArguments();
    // Make sure that an args Bundle exists.
    if (args == null)
        throw new IllegalStateException("Arguments must be supplied to " + "the AddProximityAlertFragment.");

    // Get the stopCode argument and make sure it is valid.
    stopCode = args.getString(ARG_STOPCODE);
    if (stopCode == null || stopCode.length() == 0)
        throw new IllegalArgumentException("The stopCode argument must " + "not be null or empty.");

    final Activity activity = getActivity();

    // Get the various resources.
    alertMan = AlertManager.getInstance(activity.getApplicationContext());
    locMan = (LocationManager) activity.getSystemService(Context.LOCATION_SERVICE);
    bsd = BusStopDatabase.getInstance(activity.getApplicationContext());
}

From source file:org.angellist.angellistmobile.FeedJSONAdapter.java

FeedJSONAdapter(Activity activity, JSONArray jsonArray) {
    assert activity != null;
    assert jsonArray != null;

    this.jsonArray = jsonArray;
    this.activity = activity;
    imageLoader = new ImageLoader(activity.getApplicationContext());
}

From source file:com.amytech.android.library.views.imagechooser.api.BChooser.java

public BChooser(Activity activity, int type, boolean shouldCreateThumbnails) {
    this.activity = activity;
    this.type = type;
    this.shouldCreateThumbnails = shouldCreateThumbnails;
    initDirector(activity.getApplicationContext());
}

From source file:org.catrobat.catroid.utils.UtilMerge.java

private static void showDifferentResolutionDialog(Project projectToMergeFrom, final Activity activity) {
    XmlHeader currentProject = project.getXmlHeader();
    XmlHeader headerFrom = projectToMergeFrom.getXmlHeader();
    final Project copyProjectToMergeFrom = projectToMergeFrom;
    final Activity copyActivity = activity;

    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {

        @Override/*from   ww w  .j av  a2s.c  om*/
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
            case DialogInterface.BUTTON_POSITIVE:
                if (!checkMergeConflicts(project, copyProjectToMergeFrom, copyActivity)) {
                    Log.d("MERGE", "no mergeConflicts");
                    try {
                        ProjectManager.getInstance()
                                .setProject(appendProjects(project, copyProjectToMergeFrom, copyActivity));
                        ProjectManager.getInstance().saveProject(activity.getApplicationContext());
                    } catch (IOException e) {
                        ToastUtil.showError(copyActivity, R.string.error_merge);
                        Log.e(TAG, "IOException " + e.getMessage());
                    }
                }
                break;
            }
        }
    };
    String question = activity.getString(R.string.error_different_resolutions1) + " "
            + currentProject.getProgramName() + " " + activity.getString(R.string.error_different_resolutions2)
            + " " + currentProject.getVirtualScreenHeight() + "x" + currentProject.getVirtualScreenWidth() + " "
            + activity.getString(R.string.and) + " " + headerFrom.getProgramName() + " "
            + activity.getString(R.string.error_different_resolutions2) + " "
            + headerFrom.getVirtualScreenHeight() + "x" + headerFrom.getVirtualScreenWidth() + ". "
            + activity.getString(R.string.error_different_resolutions3) + " " + currentProject.getProgramName()
            + ".";

    AlertDialog.Builder builder = new CustomAlertDialogBuilder(activity);
    builder.setTitle(R.string.warning);
    builder.setMessage(question);
    builder.setPositiveButton(activity.getString(R.string.main_menu_continue), dialogClickListener);
    builder.setNegativeButton(activity.getString(R.string.abort), dialogClickListener);
    Dialog errorDialog = builder.create();
    errorDialog.show();
}

From source file:org.xbmc.android.remote.presentation.controller.AbstractController.java

public void onCreate(Activity activity, Handler handler) {
    mActivity = activity;//  ww w.j  a va2s .c o m
    mHandler = handler;
    HostFactory.readHost(activity.getApplicationContext());
    //ClientFactory.resetClient(HostFactory.host);
}