Hello, I can not do ActionBar , so that when I click on the application icon, it returns to the previous Activity . When the application is compiled and launched, an arrow appears next to the icon, but when it is clicked, the application crashes. Must with FirstActivity to HomeActivity . But for some reason it hangs and crashes. Here's how I have:

 public class FirstActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.entry); getActionBar().setDisplayHomeAsUpEnabled(true); } public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: // app icon in action bar clicked; go home Intent intent = new Intent(this, HomeActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); return true; default: return super.onOptionsItemSelected(item); } } } 

    1 answer 1

    If I understand you correctly,

    To previous activation

    means that from HomeActivity you have launched FirstActivity . Then replace

     Intent intent = new Intent(this, HomeActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); 

    on finish ();

    • So she just closes the application. - Serjuk
    • I decided everything myself) The problem turned out to be related to HomeActivity - Serjuk
    • This is good. Strengthens understanding :) - Roman Zakharov