0

I have a very simple scenario:

In an activity the menu key is pressed, taking us to a menu. A menu option is selected taking us to an activity which presents a listview. Pressing the backbutton on the listview activity returns us to the original activity but it instantly dims and won't take input without pressing the back button or menu button to wake it up.

Is there any way of returning to the original activity so that it still responds directly to input? (clearly there is a way because I've seen plenty of applications which manage to achieve this).

The code I'm using to respond to the menu item being selected is:

public boolean onOptionsItemSelected(MenuItem item) 
{
    switch (item.getItemId())
    {
    case R.id.menu_settings:             
         startActivity(new Intent(this, MenuList.class));
            return true;
    default:
        return super.onOptionsItemSelected(item);        

    }
}

When I use the back button to return to this activity from MenuList, this activiy dims and needs to be 'woken up' using e.g. the back button.

Many thanks

Dave
  • 31
  • 1
  • 5
  • 2
    You should post some code so we can see your implementation. – A--C Dec 20 '12 at 22:47
  • Definitely post some code. Also, I strongly suggest the 'menu' is relevant here. I would suggest experimenting without the menu. Add a random button on Activity A whose onclick just starts Activity B with no frills and see how that goes. – Mike Repass Dec 20 '12 at 22:50
  • The 'menu' is the standard android menu. If I go from the original activity into another activity, the back button goes back to the original activity with the original activity nicely active – Dave Dec 20 '12 at 23:10

1 Answers1

0

I guess your newly started activity hasn't finished yet, thats why you need to press back.

You can run the following in a shell, to find out what is going on.

adb logcat -b events | grep am
Durairaj Packirisamy
  • 4,635
  • 1
  • 21
  • 27
  • I've tried creating a very simple activity, i.e one that does nothing except display a layout, and go to that when a menu item is selected. Pressing the back button has the same effect as above; the original screen is dim and won't take input. It does seem that it is to do with the fact that the second activity was started in response to a menu item being selected. Could it be that it is the _original_ activity that hasn't finished... it still thinks the menu is being processed (or something along those lines)? – Dave Dec 20 '12 at 23:43
  • N.B. My last thought seems unlikely too. And in response to the above answer, it isn't necessary to press the back button to wake the screen up; pressing the menu key has the same effect. – Dave Dec 20 '12 at 23:57
  • I have solved the problem. The xml defining the menu included a sub-menu. The sub-menu was no longer being used because I am now going to a new activity when a menu item is selected... but, I imagine Android would still try to deploy the sub-menu regardless, and this is why the original screen was dimmed on return, as if there was a menu open on top of it (the sub-menu)... even though it wasn't actually visible. Removing the sub-menu from the xml has removed the problem. – Dave Dec 21 '12 at 22:02