1

I am trying to open another activity when a button is clicked from Context Menu Action Bar. But the application is force closing when i click the button.Can't we use intents in contextual action mode?

This is my code:

@Override
    public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    switch (item.getItemId()) {
    case R.id.item_id:
    Intent i = new Intent(MainActivity.this, SecondActivity.class);
    startActivity(i);
    break;
    }
    }
Ramu
  • 123
  • 8
  • 2
    You should be able to call `startActivity()` from an `ActionMode`. Examine LogCat to see where your problem lies: https://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this – CommonsWare Jun 30 '14 at 17:51
  • LogCat is showing NullPointerException, this is working fine when i use Context Menu,but not when i use Contextual ActionMode. – Ramu Jun 30 '14 at 18:33
  • Post the complete stack trace, please. – CommonsWare Jun 30 '14 at 18:35
  • Found the problem, this helped http://stackoverflow.com/questions/3988788/what-is-a-stack-trace-and-how-can-i-use-it-to-debug-my-application-errors Thanks. – Ramu Jun 30 '14 at 18:43

0 Answers0