I like to call a menu already created an activity without using the button on the smartphone. How can I do it?
A:
Two ways to do it:
Activity.getWindow().openPanel(Window.FEATURE_OPTIONS_PANEL, event);
The event
argument is a KeyEvent
describing the key used to open the menu, which can modify how the menu is displayed based on the type of keyboard it came from.
Or... by simulating that the user has pressed the button:
IWindowManager wManager = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
KeyEvent kd = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SOFT_LEFT);
KeyEvent ku = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SOFT_LEFT);
wManager.injectKeyEvent(kd.isDown(), kd.getKeyCode(), kd.getRepeatCount(), kd.getDownTime(), kd.getEventTime(), true);
Cristian
2010-06-28 14:44:53
A:
Hi..cristian, I am getting the following errors...
IWindowManager cannot be resolved to a type ServiceManager cannot be resolved to a type
I tried to import them using
import android.os.ServiceManager; import android.view.IWindowManager;
but no luck!! can you help me out!!
Chiranjeevi
2010-10-01 07:33:32