Java Code Examples for androidx.core.app.NavUtils#navigateUpFromSameTask()
The following examples show how to use
androidx.core.app.NavUtils#navigateUpFromSameTask() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DetailsActivity.java From tracker-control-android with GNU General Public License v3.0 | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId();// Respond to the action bar's Up/Home button if (itemId == android.R.id.home) { NavUtils.navigateUpFromSameTask(this); return true; } else if (itemId == R.id.action_export_csv) { if (hasPermissions()) { exportCsv(); } return true; } else if (itemId == R.id.action_launch) { PackageManager pm = getPackageManager(); Intent intent = pm.getLaunchIntentForPackage(appPackageName); final Intent launch = (intent == null || intent.resolveActivity(pm) == null ? null : intent); if (launch != null) startActivity(launch); } return super.onOptionsItemSelected(item); }
Example 2
Source File: ActivitySettings.java From tracker-control-android with GNU General Public License v3.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: Log.i(TAG, "Up"); NavUtils.navigateUpFromSameTask(this); return true; default: return super.onOptionsItemSelected(item); } }
Example 3
Source File: ImageDetailActivity.java From graphics-samples with Apache License 2.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: NavUtils.navigateUpFromSameTask(this); return true; case R.id.clear_cache: mImageFetcher.clearCache(); Toast.makeText( this, R.string.clear_cache_complete_toast, Toast.LENGTH_SHORT).show(); return true; } return super.onOptionsItemSelected(item); }
Example 4
Source File: SettingsActivity.java From abnd-track-pomodoro-timer-app with MIT License | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: NavUtils.navigateUpFromSameTask(this); overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right); return true; } return super.onOptionsItemSelected(item); }
Example 5
Source File: SettingsActivity.java From android-popular-movies-app with Apache License 2.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); // When the home button is pressed, take the user back to the MainActivity if (id == android.R.id.home) { NavUtils.navigateUpFromSameTask(this); } return super.onOptionsItemSelected(item); }
Example 6
Source File: ActivityHelp.java From XPrivacyLua with GNU General Public License v3.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { Log.i(TAG, "Selected option " + item.getTitle()); switch (item.getItemId()) { case android.R.id.home: NavUtils.navigateUpFromSameTask(this); return true; default: return super.onOptionsItemSelected(item); } }
Example 7
Source File: NavigatableDemoActivity.java From litho with Apache License 2.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { // Respond to the action bar's Up/Home button case android.R.id.home: NavUtils.navigateUpFromSameTask(this); return true; } return super.onOptionsItemSelected(item); }
Example 8
Source File: AppCompatPreferenceActivity.java From busybox with GNU General Public License v2.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { NavUtils.navigateUpFromSameTask(this); return true; } return super.onOptionsItemSelected(item); }
Example 9
Source File: ActivitySettings.java From NetGuard with GNU General Public License v3.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: Log.i(TAG, "Up"); NavUtils.navigateUpFromSameTask(this); return true; default: return super.onOptionsItemSelected(item); } }
Example 10
Source File: ActivityPro.java From NetGuard with GNU General Public License v3.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: Log.i(TAG, "Up"); NavUtils.navigateUpFromSameTask(this); return true; case R.id.menu_challenge: menu_challenge(); return true; default: return super.onOptionsItemSelected(item); } }
Example 11
Source File: MobiComKitPeopleActivity.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { int i = item.getItemId(); if (i == android.R.id.home) { NavUtils.navigateUpFromSameTask(this); return true; // For platforms earlier than Android 3.0, triggers the search activity } else if (i == R.id.menu_search) {// if (!Utils.hasHoneycomb()) { onSearchRequested(); //} } return super.onOptionsItemSelected(item); }
Example 12
Source File: MovieDetailsActivity.java From MovieGuide with MIT License | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: NavUtils.navigateUpFromSameTask(this); } return super.onOptionsItemSelected(item); }
Example 13
Source File: BenchmarkResultActivity.java From BlurTestAndroid with Apache License 2.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: if (Build.VERSION.SDK_INT >= 16) { NavUtils.navigateUpFromSameTask(this); } else { finish(); } return true; } return super.onOptionsItemSelected(item); }
Example 14
Source File: EditTaskActivity.java From opentasks with Apache License 2.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: NavUtils.navigateUpFromSameTask(this); return true; default: break; } return super.onOptionsItemSelected(item); }
Example 15
Source File: ActivityLog.java From tracker-control-android with GNU General Public License v3.0 | 4 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); final File pcap_file = new File(getDir("data", MODE_PRIVATE), "netguard.pcap"); int itemId = item.getItemId(); if (itemId == android.R.id.home) { Log.i(TAG, "Up"); NavUtils.navigateUpFromSameTask(this); return true; } else if (itemId == R.id.menu_protocol_udp) { item.setChecked(!item.isChecked()); prefs.edit().putBoolean("proto_udp", item.isChecked()).apply(); updateAdapter(); return true; } else if (itemId == R.id.menu_protocol_tcp) { item.setChecked(!item.isChecked()); prefs.edit().putBoolean("proto_tcp", item.isChecked()).apply(); updateAdapter(); return true; } else if (itemId == R.id.menu_protocol_other) { item.setChecked(!item.isChecked()); prefs.edit().putBoolean("proto_other", item.isChecked()).apply(); updateAdapter(); return true; } else if (itemId == R.id.menu_traffic_allowed) { item.setChecked(!item.isChecked()); prefs.edit().putBoolean("traffic_allowed", item.isChecked()).apply(); updateAdapter(); return true; } else if (itemId == R.id.menu_traffic_blocked) { item.setChecked(!item.isChecked()); prefs.edit().putBoolean("traffic_blocked", item.isChecked()).apply(); updateAdapter(); return true; } else if (itemId == R.id.menu_log_live) { item.setChecked(!item.isChecked()); live = item.isChecked(); if (live) { DatabaseHelper.getInstance(this).addLogChangedListener(listener); updateAdapter(); } else DatabaseHelper.getInstance(this).removeLogChangedListener(listener); return true; } else if (itemId == R.id.menu_refresh) { updateAdapter(); return true; } else if (itemId == R.id.menu_log_resolve) { item.setChecked(!item.isChecked()); prefs.edit().putBoolean("resolve", item.isChecked()).apply(); adapter.setResolve(item.isChecked()); adapter.notifyDataSetChanged(); return true; } else if (itemId == R.id.menu_log_organization) { item.setChecked(!item.isChecked()); prefs.edit().putBoolean("organization", item.isChecked()).apply(); adapter.setOrganization(item.isChecked()); adapter.notifyDataSetChanged(); return true; } else if (itemId == R.id.menu_pcap_enabled) { item.setChecked(!item.isChecked()); prefs.edit().putBoolean("pcap", item.isChecked()).apply(); ServiceSinkhole.setPcap(item.isChecked(), ActivityLog.this); return true; } else if (itemId == R.id.menu_pcap_export) { startActivityForResult(getIntentPCAPDocument(), REQUEST_PCAP); return true; } else if (itemId == R.id.menu_log_clear) { new AsyncTask<Object, Object, Object>() { @Override protected Object doInBackground (Object... objects) { DatabaseHelper.getInstance(ActivityLog.this).clearLog(-1); if (prefs.getBoolean("pcap", false)) { ServiceSinkhole.setPcap(false, ActivityLog.this); if (pcap_file.exists() && !pcap_file.delete()) Log.w(TAG, "Delete PCAP failed"); ServiceSinkhole.setPcap(true, ActivityLog.this); } else { if (pcap_file.exists() && !pcap_file.delete()) Log.w(TAG, "Delete PCAP failed"); } return null; } @Override protected void onPostExecute (Object result) { if (running) updateAdapter(); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return true; } else if (itemId == R.id.menu_log_support) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("https://github.com/M66B/NetGuard/blob/master/FAQ.md#user-content-faq27")); if (getPackageManager().resolveActivity(intent, 0) != null) startActivity(intent); return true; } return super.onOptionsItemSelected(item); }
Example 16
Source File: SettingsActivity.java From abnd-track-pomodoro-timer-app with MIT License | 4 votes |
@Override public void onBackPressed() { super.onBackPressed(); NavUtils.navigateUpFromSameTask(this); overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right); }