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); } } }