List of usage examples for android.content Context getApplicationContext
public abstract Context getApplicationContext();
From source file:com.linkedin.platform.APIHelper.java
private void request(@NonNull Context context, int method, @NonNull String url, @Nullable JSONObject body, @Nullable ApiListener apiListener) { LISession session = LISessionManager.getInstance(context.getApplicationContext()).getSession(); if (!session.isValid()) { if (apiListener != null) { apiListener.onApiError(/*w w w . j a v a 2 s .c om*/ new LIApiError(LIApiError.ErrorType.accessTokenIsNotSet, "access toke is not set", null)); } return; } JsonObjectRequest jsonObjectRequest = buildRequest(session.getAccessToken().getValue(), method, url, body, apiListener); jsonObjectRequest.setTag(context == null ? TAG : context); QueueManager.getInstance(context).getRequestQueue().add(jsonObjectRequest); }
From source file:com.androidzeitgeist.dashwatch.dashclock.ExtensionManager.java
private ExtensionManager(Context context) { mApplicationContext = context.getApplicationContext(); mDefaultPreferences = PreferenceManager.getDefaultSharedPreferences(mApplicationContext); mValuesPreferences = mApplicationContext.getSharedPreferences("extension_data", 0); loadActiveExtensionList();/*from w ww . j a v a2 s. co m*/ }
From source file:com.aretha.content.image.AsyncImageLoader.java
private AsyncImageLoader(Context context) { mContext = context.getApplicationContext(); mFileCacheManager = new FileCacheManager(context); mExecutor = Executors.newCachedThreadPool(); mTaskList = new LinkedList<ImageLoadingTask>(); DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); mScreenWidth = displayMetrics.widthPixels; mScreenHeight = displayMetrics.heightPixels; // will notify the main thread mImageLoadedHandler = new ImageLoadHandler(context.getMainLooper()); }
From source file:net.hockeyapp.android.tasks.CheckUpdateTask.java
public void attach(WeakReference<? extends Context> weakContext) { Context ctx = null; if (weakContext != null) { ctx = weakContext.get();/*from w ww . j a v a2 s. c o m*/ } if (ctx != null) { this.context = ctx.getApplicationContext(); Constants.loadFromContext(ctx); } }
From source file:com.friedran.appengine.dashboard.client.AppEngineDashboardClient.java
public AppEngineDashboardClient(Account account, Context context, AppEngineDashboardAuthenticator.OnUserInputRequiredCallback onUserInputRequiredCallback, PostExecuteCallback postAuthenticationCallback) { mAccount = account;/*from w w w. j ava 2s . c o m*/ mApplicationContext = context.getApplicationContext(); mPostAuthenticateCallback = postAuthenticationCallback; mLastRetrievedApplications = new ArrayList<String>(); mHttpClient = new DefaultHttpClient(); mAuthenticator = new AppEngineDashboardAuthenticator(mAccount, mHttpClient, mApplicationContext, onUserInputRequiredCallback, new AppEngineDashboardAuthenticator.PostAuthenticateCallback() { @Override public void run(boolean result) { Bundle bundle = new Bundle(); bundle.putBoolean(KEY_RESULT, result); mPostAuthenticateCallback.onPostExecute(bundle); } }); }
From source file:com.tcl.lzhang1.mymusic.AppException.java
/** * Gets the crash report.//from w w w. java2 s. c om * * @param context the context * @param ex the ex * @return the crash report */ 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:net.hockeyapp.android.tasks.CheckUpdateTask.java
public CheckUpdateTask(WeakReference<? extends Context> weakContext, String urlString, String appIdentifier, UpdateManagerListener listener) { this.appIdentifier = appIdentifier; this.urlString = urlString; this.listener = listener; Context ctx = null; if (weakContext != null) { ctx = weakContext.get();/* w w w .j a va 2 s.com*/ } if (ctx != null) { this.context = ctx.getApplicationContext(); this.usageTime = Tracking.getUsageTime(ctx); Constants.loadFromContext(ctx); } }
From source file:com.cmgapps.android.util.CMGAppRater.java
private CMGAppRater(Context context) { if (context == null) { throw new IllegalArgumentException("context cannot be null"); }/*from w ww. j a v a 2 s . com*/ mContext = context.getApplicationContext(); mPref = mContext.getSharedPreferences(APP_RATE_FILE_NAME, Context.MODE_PRIVATE); mLaunchesUntilPrompt = LAUNCHES_UNTIL_PROMPT; mDaysUntilPrompt = DAYS_UNTIL_PROMPT; mDaysUntilRemindAgain = DAYS_UNTIL_REMIND_AGAIN; }
From source file:org.cvasilak.jboss.mobile.admin.net.UploadToJBossServerTask.java
public UploadToJBossServerTask(Context context, Server server, Callback callback) { this.context = context; this.client = CustomHTTPClient.getHttpClient(); this.server = server; this.callback = callback; this.gjson = ((JBossAdminApplication) context.getApplicationContext()).getJSONParser(); this.parser = new JsonParser(); // enable digest authentication if (server.getUsername() != null && !server.getUsername().equals("")) { Credentials credentials = new UsernamePasswordCredentials(server.getUsername(), server.getPassword()); client.getCredentialsProvider().setCredentials( new AuthScope(server.getHostname(), server.getPort(), AuthScope.ANY_REALM), credentials); }/*from www. j av a 2s . c om*/ }
From source file:com.battlelancer.seriesguide.extensions.ExtensionManager.java
private ExtensionManager(Context context) { Timber.d("Initializing extension manager"); mContext = context.getApplicationContext(); mSharedPrefs = mContext.getSharedPreferences(PREF_FILE_SUBSCRIPTIONS, 0); mSubscriberComponentName = new ComponentName(mContext, ExtensionSubscriberService.class); loadSubscriptions();//from w ww . j a v a 2s . c o m }