List of usage examples for android.app Activity getApplicationContext
@Override
public Context getApplicationContext()
From source file:org.mitre.svmp.net.SSLConfig.java
public SSLConfig(ConnectionInfo connectionInfo, Activity activity) { this.connectionInfo = connectionInfo; this.activity = activity; this.context = activity.getApplicationContext(); }
From source file:com.soomla.store.storefront.StorefrontController.java
public void openStore(Activity activity, IStorefrontAssets storefrontAssets) { StorefrontInfo.getInstance().initialize(storefrontAssets); Intent intent = new Intent(activity.getApplicationContext(), StorefrontActivity.class); activity.startActivity(intent);//from ww w. j a va2 s . co m StoreEventHandlers.getInstance().addEventHandler(this); }
From source file:uk.org.rivernile.edinburghbustracker.android.fragments.general.AddEditFavouriteStopFragment.java
/** * {@inheritDoc} /*from w ww . ja va 2 s . c o m*/ */ @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Bundle args = getArguments(); // Make sure that arguments exist. If they don't, throw an exception. if (args == null) throw new IllegalStateException( "There were no " + "arguments supplied to AddEditFavouriteStopsFragment."); final Activity activity = getActivity(); sd = SettingsDatabase.getInstance(activity.getApplicationContext()); // Get the arguments. stopCode = args.getString(ARG_STOPCODE); stopName = args.getString(ARG_STOPNAME); // Check that the stopCode exists. if (stopCode == null || stopCode.length() == 0) throw new IllegalArgumentException("The stopCode must not be " + "null or blank."); // If the stopName doesn't exist, try to get the existing name from // the settings database. if (stopName == null || stopName.length() == 0) stopName = sd.getNameForStop(stopCode); // Check to see if it already exists. editing = sd.getFavouriteStopExists(stopCode); // Set the appropriate title. if (editing) { activity.setTitle(getString(R.string.addeditstop_title_edit) + " " + stopCode); } else { activity.setTitle(getString(R.string.addeditstop_title_add) + " " + stopCode); } }
From source file:org.retroshare.android.ProxiedFragmentBase.java
@Override public void onAttach(Activity a) { super.onAttach(a); if (!isBound()) { Intent intent = new Intent(getActivity(), RetroShareAndroidProxy.class); a.getApplicationContext().startService(intent); a.getApplicationContext().bindService(intent, this, 0); }/*from ww w .j a v a 2 s . co m*/ }
From source file:com.stfalcon.socialauthhelper.fb.FacebookClient.java
public FacebookClient(Activity activity) { this.activity = activity; FacebookSdk.sdkInitialize(activity.getApplicationContext()); callbackManager = CallbackManager.Factory.create(); LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() { @Override/*from w w w . j av a2 s . c om*/ public void onSuccess(LoginResult loginResult) { saveToken(loginResult.getAccessToken().getToken()); new FacebookRestClient().getService(FacebookService.class) .getProfile(loginResult.getAccessToken().getToken()) .enqueue(new Callback<FacebookProfile>() { @Override public void onResponse(Call<FacebookProfile> call, Response<FacebookProfile> response) { if (callback != null) { callback.onProfileLoaded(response.body()); } } @Override public void onFailure(Call<FacebookProfile> call, Throwable t) { Log.i("TAG", "onFailure: " + t.getMessage()); } }); } @Override public void onCancel() { // App code } @Override public void onError(FacebookException exception) { Log.i("FacebookClient", "onError: " + exception.getMessage()); } }); }
From source file:org.lunci.dumbthing.fragment.ServiceFragmentBase.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); if (!mBound) { Intent intent = new Intent(activity, DataService.class); activity.getApplicationContext().bindService(intent, this, Context.BIND_AUTO_CREATE); }/*from www . j a va 2s .c om*/ }
From source file:com.mediatek.contacts.activities.ActivitiesUtils.java
public static boolean checkPhoneBookReady(final Activity activity, Bundle savedState, int subId) { if (subId > 0 && !SimCardUtils.isPhoneBookReady(subId)) { Log.w(TAG, "[checkPhoneBookReady] phone book is not ready. mSubId:" + subId); activity.finish();// www. jav a2 s .co m return true; } if ((MultiChoiceService.isProcessing(MultiChoiceService.TYPE_DELETE) || MultiChoiceService.isProcessing(MultiChoiceService.TYPE_COPY) || VCardService.isProcessing(VCardService.TYPE_IMPORT) || MultiGroupPickerFragment.isMoveContactsInProcessing() //M:FixedALPS00567939 ) && (savedState == null)) { Log.d(TAG, "[checkPhoneBookReady]delete or copy is processing "); activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(activity.getApplicationContext(), R.string.phone_book_busy, Toast.LENGTH_SHORT) .show(); } }); activity.finish(); return true; } return false; }
From source file:com.diusrex.toforeground.ToForeground.java
public boolean execute(String className, JSONArray args, CallbackContext callbackContext) throws JSONException { try {//from w w w . ja v a2s.com Intent it = new Intent("android.intent.action.MAIN"); String packageName = args.getString(0); Activity activity = this.cordova.getActivity(); it.setComponent(new ComponentName(packageName, packageName + "." + className)); it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Context context = activity.getApplicationContext(); context.startActivity(it); } catch (Exception e) { return false; } return true; }
From source file:com.imgtec.hobbyist.fragments.loginsignup.SettingsFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); appContext = activity.getApplicationContext(); }
From source file:com.apptentive.android.sdk.Apptentive.java
/** * Call this method from each of your Activities' onStart() methods. Must be called before using other Apptentive APIs * methods//from w w w .j a va 2 s . co m * * @param activity The Activity from which this method is called. */ public static void onStart(Activity activity) { try { init(activity); ActivityLifecycleManager.activityStarted(activity); if (runningActivities == 0) { PayloadSendWorker.appWentToForeground(activity.getApplicationContext()); MessagePollingWorker.appWentToForeground(activity.getApplicationContext()); } runningActivities++; } catch (Exception e) { Log.w("Error starting Apptentive Activity.", e); MetricModule.sendError(activity.getApplicationContext(), e, null, null); } }