private void requestChangeBatteryOptimizations () { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { Intent intent = new Intent(); String packageName = getActivity().getPackageName(); PowerManager pm = (PowerManager) getActivity().getSystemService(Context.POWER_SERVICE); if (pm.isIgnoringBatteryOptimizations(packageName)) intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS); else { intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); intent.setData(Uri.parse("package:" + packageName)); } getActivity().startActivity(intent); } }
getActivity().startActivity(i); break;
/** * Just a helper methods in case the user blocks permission. * It goes to your application settings page for the user to enable permission again. */ public void goToSettings() { final FragmentActivity fragmentActivity = this.activityReference.get(); if (fragmentActivity != null) { fragmentActivity.startActivity(new Intent( Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", fragmentActivity.getPackageName(), null))); } }
private void showTrailer(Kino kino) { String url = kino.getTrailerSearchUrl(); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); requireActivity().startActivity(intent); }
@Override public boolean onPreferenceClick(Preference preference) { String key = preference.getKey(); if ("opensource_licenses".equals(key)) { Intent intent = new Intent(getContext(), HtmlActionActivity.class); intent.putExtra(Intent.EXTRA_TITLE, preference.getTitle()); intent.putExtra(HtmlActionActivity.EXTRA_URL, "file:///android_res/raw/licenses.html"); getActivity().startActivity(intent); } else if ("help".equals(key)) { Intent intent = new Intent(getContext(), HtmlActionActivity.class); intent.putExtra(Intent.EXTRA_TITLE, preference.getTitle()); intent.putExtra(HtmlActionActivity.EXTRA_URL, "file:///android_res/raw/help.html"); getActivity().startActivity(intent); } else if ("pref_app_language".equals(key)) { showLanguageDialog(preference); } else if ("shell_start".equals(key)){ showShellStart(); } return false; } }
private void switchLanguage() { LangHelper.updateLanguage(getContext()); LangHelper.updateLanguage(getContext().getApplicationContext()); Intent it = new Intent(getActivity(), MainActivity.class); it.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); it.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); getActivity().startActivity(it); getActivity().finish(); }
@Override public void onItemClicked(View view) { Intent intent = new Intent(getActivity(), AccountSettingsActivity.class); intent.putExtra(IntentExtra.ACCOUNT_NAME.key, MyContextHolder.get().accounts().fromActorId(mItemId).getAccountName()); getActivity().startActivity(intent); }