List of usage examples for android.app Activity getApplicationContext
@Override
public Context getApplicationContext()
From source file:com.nick.scalpel.core.AutoFoundWirer.java
@Override public void wire(Activity activity, Field field) { WireParam param = getParam(activity, field); if (param == null) return;//from w w w . ja v a2 s. c o m switch (param.type) { case VIEW: wire(activity.getWindow().getDecorView(), activity, field); break; default: wire(activity.getApplicationContext(), activity, field); break; } }
From source file:edu.rit.csh.androidwebnews.HttpsConnector.java
public HttpsConnector(Activity activity) { this.activity = activity; context = activity.getApplicationContext(); sharedPref = PreferenceManager.getDefaultSharedPreferences(activity); }
From source file:org.jboss.aerogear.android.pipe.loader.LoaderAdapter.java
public LoaderAdapter(Activity activity, Pipe<T> pipe, String name) { this.pipe = pipe; this.requestBuilder = pipe.getRequestBuilder(); this.responseParser = pipe.getResponseParser(); this.manager = activity.getLoaderManager(); this.applicationContext = activity.getApplicationContext(); this.name = name; this.handler = new Handler(Looper.getMainLooper()); this.activity = activity; }
From source file:ca.bitwit.postcard.PostcardAdaptor.java
/** * Cordova Plugin Overrides//w w w. j a va 2s. c o m */ public PostcardAdaptor(Activity activity, WebView webView) { Log.d("PostcardApplication", "Initialized"); NetworksManager.INSTANCE.adaptor = this; this.activity = activity; this.webView = webView; Context context = activity.getApplicationContext(); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webView.addJavascriptInterface(this, "PostcardApplication"); webView.loadUrl("file:///android_asset/www/index.html"); this.properties = new Properties(); String propFileName = "postcard.properties"; try { InputStream inputStream = context.getAssets().open(propFileName); if (inputStream != null) { this.properties.load(inputStream); } else { throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath"); } } catch (IOException e) { e.printStackTrace(); } this.networkAccountDataSource = new NetworkAccountDataSource(context); this.networkAccountDataSource.open(); this.personDataSource = new PersonDataSource(context); this.personDataSource.open(); this.tagDataSource = new TagDataSource(context); this.tagDataSource.open(); }
From source file:com.microsoft.rightsmanagement.ui.UserPolicyViewerActivity.java
/** * Show UI./*from www .j a v a 2s. com*/ * * @param requestCode the request code for startActivityForResult * @param parentActivity the parent activity that invokes startActivityForResult * @param userPolicy user policy instance that provides data to display on the UI * @param supportedRights rights to check access for and display * @param policyViewerActivityRequestOption PolicyViewerActivityRequestOptions * @param policyViewerActivityCompletionCallback callback that's invoked upon completion of activity. * @throws InvalidParameterException the invalid parameter exception */ public static void show(int requestCode, Activity parentActivity, UserPolicy userPolicy, LinkedHashSet<String> supportedRights, int policyViewerActivityRequestOption, CompletionCallback<Integer> policyViewerActivityCompletionCallback) { Logger.ms(TAG, "show"); parentActivity = validateActivityInputParameter(parentActivity); userPolicy = validateUserPolicyInputParameter(userPolicy); policyViewerActivityCompletionCallback = validateCompletionCallbackInputParameter( policyViewerActivityCompletionCallback); policyViewerActivityRequestOption = validatePolicyViewerActivityRequestOption( policyViewerActivityRequestOption); // put callback int requestCallbackId = policyViewerActivityCompletionCallback.hashCode(); sCallbackManager.putWaitingRequest(requestCallbackId, policyViewerActivityCompletionCallback); // set launch intent Intent intent = new Intent(parentActivity, UserPolicyViewerActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(REQUEST_CALLBACK_ID, requestCallbackId); intent.putExtra(REQUEST_RESULT_POLICY_VIEWER_OPTIONS, policyViewerActivityRequestOption); intent.putExtra(REQUEST_RESULT_USER_POLICY_MODEL, (new UserPolicyModel(userPolicy, supportedRights, parentActivity.getApplicationContext()))); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); parentActivity.startActivityForResult(intent, requestCode); Logger.me(TAG, "show"); }
From source file:net.archenemy.archenemyapp.presenter.BackgroundWorkerFragment.java
/** * *///from w w w. jav a 2 s. com @Override public void onAttach(Activity activity) { super.onAttach(activity); if (activity != null) { callback = (ProviderRequestCallback) activity; this.activity = activity; users = DataAdapter.getInstance().getSocialMediaUsers(activity); isAttached = true; context = activity.getApplicationContext(); // make pending requests if (pendingTwitterUserRequest) { pendingTwitterUserRequest = false; requestTwitterUsers(); } if (pendingFacebookUserRequest) { pendingFacebookUserRequest = false; requestFacebookUsers(); } if (pendingTwitterFeedRequest) { pendingTwitterFeedRequest = false; requestTwitterFeed(); } if (pendingFacebookFeedRequest) { pendingFacebookFeedRequest = false; requestFacebookFeed(); } } }
From source file:com.mbientlab.metawear.starter.DeviceSetupActivityFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Activity owner = getActivity(); if (!(owner instanceof FragmentSettings)) { throw new ClassCastException("Owning activity must implement the FragmentSettings interface"); }/*from w ww .j a v a2 s . co m*/ settings = (FragmentSettings) owner; owner.getApplicationContext().bindService(new Intent(owner, MetaWearBleService.class), this, Context.BIND_AUTO_CREATE); }
From source file:com.adguard.android.service.FilterServiceImpl.java
@Override public void checkFiltersUpdates(Activity activity) { LOG.info("Start manual filters updates check"); ServiceLocator.getInstance(activity.getApplicationContext()).getPreferencesService() .setLastUpdateCheck(new Date().getTime()); ProgressDialog progressDialog = showProgressDialog(activity, R.string.checkUpdatesProgressDialogTitle, R.string.checkUpdatesProgressDialogMessage); DispatcherThreadPool.getInstance().submit(FILTERS_UPDATE_QUEUE, new CheckUpdatesTask(activity, progressDialog)); LOG.info("Submitted filters update task"); }
From source file:nuclei.media.MediaInterface.java
@TargetApi(21) public MediaInterface(Activity activity, MediaId mediaId, MediaInterfaceCallback callback) { mLActivity = activity;/* w w w .j ava 2 s .c o m*/ mCallbacks = callback; mPlayerControls = new MediaPlayerController(mediaId); mPlayerControls.setMediaControls(mCallbacks, null); mMediaBrowser = new MediaBrowserCompat(activity.getApplicationContext(), new ComponentName(activity, MediaService.class), new MediaBrowserCompat.ConnectionCallback() { @Override public void onConnected() { MediaInterface.this.onConnected(); } }, null); mMediaBrowser.connect(); mSurfaceId = SURFACE_ID.incrementAndGet(); if (SURFACE_ID.longValue() == Long.MAX_VALUE) SURFACE_ID.set(1); }
From source file:org.catrobat.catroid.cast.CastManager.java
public synchronized void initializeCast(Activity activity) { initializingActivity = activity;//from w w w . j av a 2 s . co m if (mediaRouter != null) { return; } deviceAdapter = new CastDevicesAdapter(activity, R.layout.fragment_cast_device_list_item, routeInfos); mediaRouter = MediaRouter.getInstance(activity.getApplicationContext()); mediaRouteSelector = new MediaRouteSelector.Builder() .addControlCategory(CastMediaControlIntent.categoryForCast(Constants.REMOTE_DISPLAY_APP_ID)) .build(); setCallback(); }