List of usage examples for android.app Activity getApplicationContext
@Override
public Context getApplicationContext()
From source file:com.fb.audiencenetwork.scrollapp.NasaRequester.java
public NasaRequester(Activity activity) { mCalendar = Calendar.getInstance(); mDateFormat = new SimpleDateFormat("yyyy-MM-dd"); mResponseListener = (NasaResponse) activity; mContext = activity.getApplicationContext(); mClient = new OkHttpClient(); mLoadingData = false;//from w ww . j a v a 2 s. c o m }
From source file:com.ap.github.base.BaseFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); mContext = activity.getBaseContext(); mApplicationContext = activity.getApplicationContext(); mActivity = activity;/*from ww w . j a va 2 s.com*/ }
From source file:com.mbientlab.metawear.tutorial.multimw.MainActivityFragment.java
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Activity owner = getActivity(); owner.getApplicationContext().bindService(new Intent(owner, BtleService.class), this, Context.BIND_AUTO_CREATE); }
From source file:net.olejon.mdapp.MedicationFelleskatalogenFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override/*ww w . ja v a 2s .c o m*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) { ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.fragment_medication_felleskatalogen, container, false); // Activity final Activity activity = getActivity(); // Context final Context context = activity.getApplicationContext(); // Tools final MyTools mTools = new MyTools(context); // Arguments Bundle bundle = getArguments(); final String pageUri = bundle.getString("uri"); // Progress bar final ProgressBar progressBar = (ProgressBar) activity .findViewById(R.id.medication_toolbar_progressbar_horizontal); // Toolbar final LinearLayout toolbarSearchLayout = (LinearLayout) activity .findViewById(R.id.medication_toolbar_search_layout); final EditText toolbarSearchEditText = (EditText) activity.findViewById(R.id.medication_toolbar_search); // Web view WEBVIEW = (WebView) viewGroup.findViewById(R.id.medication_felleskatalogen_content); WebSettings webSettings = WEBVIEW.getSettings(); webSettings.setJavaScriptEnabled(true); WEBVIEW.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (!mTools.isDeviceConnected()) { mTools.showToast(getString(R.string.device_not_connected), 0); return true; } else if (url.matches("^https?://.*?\\.pdf$")) { mTools.downloadFile(view.getTitle(), url); return true; } return false; } }); WEBVIEW.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { if (newProgress == 100) { progressBar.setVisibility(View.INVISIBLE); } else { progressBar.setVisibility(View.VISIBLE); progressBar.setProgress(newProgress); toolbarSearchLayout.setVisibility(View.GONE); toolbarSearchEditText.setText(""); } } }); if (savedInstanceState == null) { WEBVIEW.loadUrl(pageUri); } else { WEBVIEW.restoreState(savedInstanceState); } return viewGroup; }
From source file:org.alfresco.mobile.android.application.accounts.oauth.OAuthRefreshTokenCallback.java
public OAuthRefreshTokenCallback(Activity activity, Account acc, CloudSession session) { this.activity = activity; this.appContext = activity.getApplicationContext(); this.acc = acc; this.session = session; }
From source file:com.dabay6.libraries.androidshared.ui.dialogs.BaseDialogFragment.java
/** * {@inheritDoc}/*from w w w. ja v a 2s .co m*/ */ @Override public void onAttach(final Activity activity) { super.onAttach(activity); applicationContext = activity.getApplicationContext(); }
From source file:com.yangtsaosoftware.pebblemessenger.activities.SettingFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); ((NavigationActivity) activity).onSectionAttached(positionIndex); _context = activity.getApplicationContext(); }
From source file:net.olejon.mdapp.MedicationNlhFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override// w w w . j a v a 2 s . com public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) { ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.fragment_medication_nlh, container, false); // Activity final Activity activity = getActivity(); // Context final Context context = activity.getApplicationContext(); // Tools final MyTools mTools = new MyTools(context); // Arguments Bundle bundle = getArguments(); final String pageUri = bundle.getString("uri"); // Progress bar final ProgressBar progressBar = (ProgressBar) activity .findViewById(R.id.medication_toolbar_progressbar_horizontal); // Toolbar final LinearLayout toolbarSearchLayout = (LinearLayout) activity .findViewById(R.id.medication_toolbar_search_layout); final EditText toolbarSearchEditText = (EditText) activity.findViewById(R.id.medication_toolbar_search); // Web view WEBVIEW = (WebView) viewGroup.findViewById(R.id.medication_nlh_content); WebSettings webSettings = WEBVIEW.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setAppCacheEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setAppCachePath(context.getCacheDir().getAbsolutePath()); webSettings.setCacheMode(WebSettings.LOAD_DEFAULT); WEBVIEW.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (!mTools.isDeviceConnected()) { mTools.showToast(getString(R.string.device_not_connected), 0); return true; } else if (url.matches(".*/[^#]+#[^/]+$")) { WEBVIEW.loadUrl(url.replaceAll("#[^/]+$", "")); return true; } else if (url.matches("^https?://.*?\\.pdf$")) { mTools.downloadFile(view.getTitle(), url); return true; } return false; } }); WEBVIEW.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { if (newProgress == 100) { progressBar.setVisibility(View.INVISIBLE); } else { progressBar.setVisibility(View.VISIBLE); progressBar.setProgress(newProgress); toolbarSearchLayout.setVisibility(View.GONE); toolbarSearchEditText.setText(""); } } }); if (savedInstanceState == null) { WEBVIEW.loadUrl(pageUri); } else { WEBVIEW.restoreState(savedInstanceState); } return viewGroup; }
From source file:net.saga.aeroconf.app.ui.fragment.ScheduleFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); if (adapter == null) { adapter = new ScheduleAdapter(calendar, activity.getApplicationContext()); }/*from w w w. j a va 2 s . c o m*/ resolver = getActivity().getContentResolver(); }
From source file:com.apptentive.android.sdk.Apptentive.java
/** * Opens the Apptentive Message Center UI Activity, and allows custom data to be sent with the next message the user * sends. If the user sends multiple messages, this data will only be sent with the first message sent after this * method is invoked. Additional invocations of this method with custom data will repeat this process. * * @param activity The Activity from which to launch the Message Center * @param customData A Map of key/value Strings that will be sent with the next message. *///from ww w . j av a 2 s . c o m public static void showMessageCenter(Activity activity, Map<String, String> customData) { try { ApptentiveMessageCenter.show(activity, true, customData); } catch (Exception e) { Log.w("Error starting Apptentive Activity.", e); MetricModule.sendError(activity.getApplicationContext(), e, null, null); } }