List of usage examples for android.app Activity getApplicationContext
@Override
public Context getApplicationContext()
From source file:org.catrobat.catroid.utils.UtilMerge.java
private static Project loadProjectContent(String projectName, Activity activity) throws LoadingProjectException, OutdatedVersionProjectException, CompatibilityProjectException { if (project.getName().equals(projectName)) { throw new LoadingProjectException(activity.getString(R.string.error_load_project)); }/*ww w . j a va 2s . c o m*/ Project projectToMergeInto = project; ProjectManager.getInstance().loadProject(projectName, activity.getApplicationContext()); Project projectToMergeFrom = ProjectManager.getInstance().getCurrentProject(); project = projectToMergeInto; return projectToMergeFrom; }
From source file:com.mediatek.contacts.activities.ActivitiesUtils.java
/** For CR ALPS01541210 */ public static boolean checkContactsProcessIsBusy(final Activity activity) { // Since busy return directly no receiver is registered boolean isProcessBusy = ContactsApplicationEx.isContactsApplicationBusy(); Log.d(TAG, "[checkContactsProcessIsBusy]isProcessBusy = " + isProcessBusy); if (isProcessBusy) { activity.runOnUiThread(new Runnable() { @Override/*w w w .j av a2s. c om*/ public void run() { MtkToast.toast(activity.getApplicationContext(), R.string.phone_book_busy); } }); activity.finish(); return true; } return false; }
From source file:de.spiritcroc.modular_remote.Util.java
public static void suggestPreviousIps(final Fragment fragment, final AutoCompleteTextView textView) { Activity activity = fragment.getActivity(); final TcpConnectionManager tcpConnectionManager = TcpConnectionManager .getInstance(activity.getApplicationContext()); textView.setAdapter(new ArrayAdapter<>(activity, android.R.layout.simple_list_item_1, tcpConnectionManager.getConnectionSuggestions())); if (fragment instanceof ReceiverIpSelectorUser) { textView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override//w w w . j a va 2s.c om public void onItemClick(AdapterView<?> parent, View view, int position, long id) { TcpConnectionManager.TcpConnection connection = tcpConnectionManager .getTcpConnection(textView.getText().toString()); ((ReceiverIpSelectorUser) fragment).setReceiverType(connection.getType()); } }); } }
From source file:com.apptentive.android.dev.InteractionsActivity.java
public static boolean forceShowRatingsPromptInteraction(Activity activity, String eventName) { if (eventName == null) { Log.w("Event name is null. Can't force show Ratings Prompt."); return false; }/*from ww w .ja v a 2 s . c o m*/ try { String eventLabel = EngagementModule.generateEventLabel("local", "app", eventName); Log.d("Force Showing Ratings Prompt at: ", eventLabel); Interaction interaction = getRatingsPromptInteraction(activity, eventLabel); if (interaction != null) { CodePointStore.storeCodePointForCurrentAppVersion(activity.getApplicationContext(), eventLabel); EventManager.sendEvent(activity.getApplicationContext(), new Event(eventLabel, (JSONObject) null)); CodePointStore.storeInteractionForCurrentAppVersion(activity, interaction.getId()); EngagementModule.launchInteraction(activity, interaction); return true; } else { Toast.makeText(activity, "No Ratings Prompt available for that Interaction.", Toast.LENGTH_SHORT) .show(); } } catch (Exception e) { MetricModule.sendError(activity.getApplicationContext(), e, null, null); Log.e("Error:", e); } return false; }
From source file:it.imwatch.nfclottery.MainActivity.java
/** * Sets up the dispatching of NFC events a the foreground Activity. * * @param activity The {@link android.app.Activity} to setup the foreground dispatch for * @param adapter The {@link android.nfc.NfcAdapter} to setup the foreground dispatch for *//*w ww .j a va2s . c om*/ public static void setupForegroundDispatch(final Activity activity, NfcAdapter adapter) { if (adapter != null) { final Intent intent = new Intent(activity.getApplicationContext(), activity.getClass()); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); final PendingIntent pendingIntent = PendingIntent.getActivity(activity.getApplicationContext(), 0, intent, 0); IntentFilter[] filters = new IntentFilter[1]; String[][] techList = new String[][] {}; // Notice that this is the same filter we define in our manifest. // This ensures we're not stealing events for other types of NDEF. filters[0] = new IntentFilter(); IntentFilter filter = filters[0]; filter.addAction(NfcAdapter.ACTION_NDEF_DISCOVERED); filter.addCategory(Intent.CATEGORY_DEFAULT); try { filter.addDataType(MIME_VCARD); filter.addDataType(MIME_XVCARD); } catch (IntentFilter.MalformedMimeTypeException e) { throw new RuntimeException("Mime type not supported."); } adapter.enableForegroundDispatch(activity, pendingIntent, filters, techList); } }
From source file:de.baumann.browser.helper.helper_main.java
private static void openFile(Activity activity, File file, String string, View view) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); Uri contentUri = FileProvider.getUriForFile(activity, activity.getApplicationContext().getPackageName() + ".provider", file); intent.setDataAndType(contentUri, string); } else {/* w ww.j a va 2s . co m*/ intent.setDataAndType(Uri.fromFile(file), string); } try { activity.startActivity(intent); } catch (ActivityNotFoundException e) { Snackbar.make(view, R.string.toast_install_app, Snackbar.LENGTH_LONG).show(); } }
From source file:com.mediatek.contacts.activities.ActivitiesUtils.java
public static boolean deleteContact(Activity activity) { Log.i(TAG, "[deleteContact]..."); if (MultiChoiceService.isProcessing(MultiChoiceService.TYPE_DELETE)) { Toast.makeText(activity, R.string.contact_delete_all_tips, Toast.LENGTH_SHORT).show(); return true; } else if (VCardService.isProcessing(VCardService.TYPE_IMPORT) || VCardService.isProcessing(VCardService.TYPE_EXPORT)) { Toast.makeText(activity, R.string.contact_import_export_tips, Toast.LENGTH_SHORT).show(); return true; }// w ww . j a v a2 s . c o m activity.startActivity(new Intent() .setClassName(activity.getApplicationContext(), "com.mediatek.contacts.list.ContactListMultiChoiceActivity") .setAction(com.mediatek.contacts.util.ContactsIntent.LIST.ACTION_DELETE_MULTI_CONTACTS)); return true; }
From source file:com.mediatek.contacts.activities.ActivitiesUtils.java
public static boolean isDeleteingContact(final Activity activity) { if (MultiChoiceService.isProcessing(MultiChoiceService.TYPE_DELETE) || MultiChoiceService.isProcessing(MultiChoiceService.TYPE_COPY) || VCardService.isProcessing(VCardService.TYPE_IMPORT) || MultiGroupPickerFragment.isMoveContactsInProcessing()// M:ALPS00567939 || ContactSaveService.isGroupTransactionProcessing()) { // / M: Fixed ALPS00542175 Log.d(TAG, "delete or copy is processing "); activity.runOnUiThread(new Runnable() { @Override/*from w w w. j ava 2 s .c om*/ 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.pdi.hybridge.boilerplate.action.InitTask.java
public InitTask(Activity activity) { mContext = activity.getApplicationContext(); }
From source file:eu.inmite.apps.smsjizdenka.framework.fragment.BaseFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); mContext = activity.getApplicationContext(); mApp = (App) activity.getApplication(); }