List of usage examples for android.content Context getApplicationContext
public abstract Context getApplicationContext();
From source file:net.kourlas.voipms_sms.Notifications.java
private Notifications(Context context) { this.applicationContext = context.getApplicationContext(); this.preferences = Preferences.getInstance(applicationContext); this.gcm = Gcm.getInstance(applicationContext); this.notificationIds = new HashMap<>(); this.notificationIdCount = 0; }
From source file:io.github.acashjos.anarch.Session.java
/** * constructor/*from ww w . ja va 2 s.co m*/ * @param applicationContext applicationContext */ private Session(Context applicationContext) { this.pref = applicationContext.getApplicationContext().getSharedPreferences("cache", Context.MODE_PRIVATE); cookies = pref.getString("session", ""); }
From source file:com.microsoft.azure.engagement.shared.EngagementDataPushReceiver.java
@Override protected Boolean onDataPushStringReceived(Context context, String category, String body) { String encodedCategory = encodeURIComponent(category); String encodedBody = encodeURIComponent(body); addDataPush(context.getApplicationContext(), encodedCategory, encodedBody, false); EngagementShared.instance().checkDataPush(); return true;/*from w w w .ja v a 2 s . co m*/ }
From source file:com.nostra13.universalimageloader.core.download.BaseImageDownloader.java
public BaseImageDownloader(Context context) { this.context = context.getApplicationContext(); this.connectTimeout = DEFAULT_HTTP_CONNECT_TIMEOUT; this.readTimeout = DEFAULT_HTTP_READ_TIMEOUT; }
From source file:com.atinternet.tracker.CrashDetectionHandler.java
/** * Default constructor/* w ww . j a v a 2 s. co m*/ * * @param context Context * @param defaultHandler Thread.UncaughtExceptionHandler */ public CrashDetectionHandler(Context context, Thread.UncaughtExceptionHandler defaultHandler) { this.defaultHandler = defaultHandler; this.context = context; preferences = context.getApplicationContext().getSharedPreferences(TrackerConfigurationKeys.PREFERENCES, Context.MODE_PRIVATE); }
From source file:org.yaoha.ApiConnector.java
public ApiConnector() { String applicationVersion = ""; Context ctx = YaohaActivity.getStaticApplicationContext(); try {/*from w w w . j a va 2 s . c om*/ applicationVersion = ctx.getApplicationContext().getPackageManager() .getPackageInfo(ctx.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { applicationVersion = "version_unset"; } userAgentHeader = new BasicHeader("User-Agent", "YAOHA/" + applicationVersion + " (Android)"); setConsumer(); client = new DefaultHttpClient(); }
From source file:luki.x.XConfig.java
@SuppressWarnings("deprecation") private void initTagKey(Context context, String name) { try {//from w w w . j ava2 s. c o m sContext = context.getApplicationContext(); WindowManager wm = (WindowManager) sContext.getSystemService(Context.WINDOW_SERVICE); SCREEN_WIDTH = wm.getDefaultDisplay().getWidth(); Class<?> clazz = Class.forName(sContext.getPackageName() + name); Object obj = clazz.newInstance(); Field[] s = clazz.getDeclaredFields(); HOLDER_KEY = s[0].getInt(obj); HOLDER_POSITION = s[1].getInt(obj); } catch (Exception e) { try { initTagKey(sContext, TAG_KEY_CLASS[tagKeyPos++]); } catch (Exception e1) { XLog.e("InjectAdapter", "you should have at least two same resource type in 'res'."); } } }
From source file:com.google.android.gcm.demo.logic.DeviceGroupsHelper.java
public DeviceGroupsHelper(Context context) { mContext = context.getApplicationContext(); mLogger = new LoggingService.Logger(mContext); mSenders = SenderCollection.getInstance(mContext); }
From source file:cn.edu.szjm.support.http.IgnitedHttp.java
/** * Registers a broadcast receiver with the application context that will take care of updating * proxy settings when failing over between 3G and Wi-Fi. <b>This requires the * {@link Manifest.permission#ACCESS_NETWORK_STATE} permission</b>. * //from w w w . jav a 2 s .c o m * @param context * the context used to retrieve the app context */ public void listenForConnectivityChanges(Context context) { context.getApplicationContext().registerReceiver(new ConnectionChangedBroadcastReceiver(this), new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); }
From source file:com.ibm.pickmeup.utils.MessageFactory.java
private MessageFactory(Context context) { this.context = context; settings = context.getSharedPreferences(Constants.SETTINGS, 0); app = (PickMeUpApplication) context.getApplicationContext(); }