List of usage examples for android.content Context getApplicationContext
public abstract Context getApplicationContext();
From source file:org.whispersystems.textsecure.push.PushServiceSocket.java
public PushServiceSocket(Context context, String serviceUrl, TrustStore trustStore, String localNumber, String password) {//from ww w .j a v a 2 s. c om this.context = context.getApplicationContext(); this.serviceUrl = serviceUrl; this.localNumber = localNumber; this.password = password; this.trustManagers = initializeTrustManager(trustStore); }
From source file:com.mparticle.internal.ConfigManager.java
public ConfigManager(Context context, MParticle.Environment environment, String apiKey, String apiSecret) { mContext = context.getApplicationContext(); mPreferences = mContext.getSharedPreferences(PREFERENCES_FILE, Context.MODE_PRIVATE); sLocalPrefs = new AppConfig(mContext, environment, mPreferences, apiKey, apiSecret); }
From source file:com.ademsha.appnotifico.NotificationHubCommandReceiver.java
private void getAllActiveNotifications(Context context) { JSONArray notifications = new JSONArray(); for (StatusBarNotification statusBarNotification : notificationHub.getActiveNotifications()) { notifications.put(NotificationDataHelper.getStatusBarNotificationDataAsJSON(statusBarNotification)); }/* w ww. j a v a 2 s .c o m*/ if (notifications.length() > 0) { Intent dataIntent = new Intent(NotificationHubConfig.NOTIFICATION_HUB_DATA_RECIEVER_INTENT); dataIntent.putExtra("command", "get-all"); dataIntent.putExtra("data", " " + notifications.toString() + "\n"); context.getApplicationContext().sendBroadcast(dataIntent); } }
From source file:org.mythtv.service.guide.v25.ProgramGuideHelperV25.java
public boolean process(final Context context, final LocationProfile locationProfile) { Log.v(TAG, "process : enter"); if (!NetworkHelper.getInstance().isMasterBackendConnected(context, locationProfile)) { Log.w(TAG, "process : Master Backend '" + locationProfile.getHostname() + "' is unreachable"); return false; }//from w w w.j av a 2 s .co m mMainApplication = (MainApplication) context.getApplicationContext(); mMythServicesTemplate = (MythServicesTemplate) MythAccessFactory.getServiceTemplateApiByVersion(mApiVersion, locationProfile.getUrl()); if (null == mMythServicesTemplate) { Log.w(TAG, "process : Master Backend '" + locationProfile.getHostname() + "' is unreachable"); return false; } boolean passed = true; try { downloadProgramGuide(context, locationProfile); } catch (Exception e) { Log.e(TAG, "process : error", e); passed = false; } Log.v(TAG, "process : exit"); return passed; }
From source file:com.aniruddhc.acemusic.player.GMusicHelpers.GMusicClientCalls.java
private GMusicClientCalls(Context context) { mHttpClient = new GMusicHttpClient(); mContext = context;//from w w w . j av a 2 s.c om mCookieStore = new PersistentCookieStore(context.getApplicationContext()); mHttpClient.setCookieStore(mCookieStore); mHttpClient.setUserAgent(""); }
From source file:com.mutu.gpstracker.streaming.CustomUpload.java
private void notifyError(Context context, Exception e) { Log.e(TAG, "Custom upload failed", e); String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns); int icon = R.drawable.ic_maps_indicator_current_position; CharSequence tickerText = context.getText(R.string.customupload_failed); long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); Context appContext = context.getApplicationContext(); CharSequence contentTitle = tickerText; CharSequence contentText = e.getMessage(); Intent notificationIntent = new Intent(context, CustomUpload.class); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(appContext, contentTitle, contentText, contentIntent); notification.flags = Notification.FLAG_AUTO_CANCEL; mNotificationManager.notify(NOTIFICATION_ID, notification); }
From source file:com.appsimobile.appsii.module.weather.WeatherLoadingService.java
public WeatherLoadingService(Context context) { mContext = context.getApplicationContext(); AppInjector.inject(this); }
From source file:com.owncloud.android.oc_framework.operations.RemoteOperation.java
/** * Asynchronously executes the remote operation * //from www. j av a 2s . c o m * This method should be used whenever an ownCloud account is available, instead of {@link #execute(WebdavClient)}. * * @param account ownCloud account in remote ownCloud server to reach during the execution of the operation. * @param context Android context for the component calling the method. * @param listener Listener to be notified about the execution of the operation. * @param listenerHandler Handler associated to the thread where the methods of the listener objects must be called. * @return Thread were the remote operation is executed. */ public final Thread execute(Account account, Context context, OnRemoteOperationListener listener, Handler listenerHandler, Activity callerActivity) { if (account == null) throw new IllegalArgumentException("Trying to execute a remote operation with a NULL Account"); if (context == null) throw new IllegalArgumentException("Trying to execute a remote operation with a NULL Context"); mAccount = account; mContext = context.getApplicationContext(); mCallerActivity = callerActivity; mClient = null; // the client instance will be created from mAccount and mContext in the runnerThread to create below mListener = listener; mListenerHandler = listenerHandler; Thread runnerThread = new Thread(this); runnerThread.start(); return runnerThread; }
From source file:com.amazon.android.contentbrowser.helper.AuthHelper.java
/** * Constructor./*from w w w . j a v a 2 s . c o m*/ * * @param context Context. * @param contentBrowser Content browser. */ public AuthHelper(Context context, ContentBrowser contentBrowser) { mAppContext = context.getApplicationContext(); mContentBrowser = contentBrowser; // Get default Auth interface without creating a new one. try { mIAuthentication = (IAuthentication) ModuleManager.getInstance() .getModule(IAuthentication.class.getSimpleName()).getImpl(true); } catch (Exception e) { Log.e(TAG, "No Auth Interface interface attached.", e); } IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(LogoutSettingsFragment.LOGOUT_BUTTON_BROADCAST_INTENT_ACTION); LocalBroadcastManager.getInstance(mAppContext).registerReceiver(mLocalBroadcastReceiver, intentFilter); //AuthHelper is initialized, broadcast initial authentication status isAuthenticated().subscribe(isAuthenticatedResultBundle -> { boolean result = isAuthenticatedResultBundle.getBoolean(AuthHelper.RESULT); broadcastAuthenticationStatus(result); }); }