When I click the back button, Android goes to the previous action. Is it possible to set up a regular (reverse) activity for each type of activity or set the "Back" button on the applicationโs home mode?
Help or tips would be great :)
You will have to override onBackPressed () from your activity:
@Override public void onBackPressed() { super.onBackPressed(); startActivity(new Intent(ThisActivity.this, NextActivity.class)); finish(); }
public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { Intent i = new Intent(this.class, yourcustomclass); startActivity(i); finish(); } }
Yes, maybe just add this method to your activity:
public void onBackPressed() { //Do the stuff you want on backbutton pressed. }
Yes, you should @ override the onBackPressed () function and create an Itent to go where you want.
You can override
@Override public void onBackPressed(){ }
If you need to go back when you press the ActionBar back arrow (Home). overide onSupportNavigateUp ()
@Override public boolean onSupportNavigateUp() { //onBackPressed(); //this will be go to parent activity //******************// // Your intent here // //******************// return true; }
Source: https://habr.com/ru/post/952361/More articles:THREE.js: Why does my object flip over while traveling on a spline? - mathHow to set multiple values โโin a list using lambda expression? - c #why the object identifier of a wrapper class does not work as a reference variable - javaconcatenating arrays in python such as matlab without knowing the size of the output array - pythonhow to determine if window.location failed? - javascriptWe still need AreaRegistration.RegisterAllAreas () in Global.asax in a pure ASP.NET Web API service without MVC - c #Can I execute Google Apps Script code from the Chrome extension? - google-chrome-extensionHow to get a sound graph for a waveform sound file? - iosCan I specify multiple endpoints for notification of Sendgrid events? - sendgridSystemVerilog system unit versus traditional test bench - unit-testingAll Articles