开发者

Replicate physical keyboard on the Android emulator

开发者 https://www.devze.com 2023-02-11 02:25 出处:网络
I have a couple of reports on my recent app of a bug related to a phone with a physical key开发者_C百科board, an EditText, and an orientation change.

I have a couple of reports on my recent app of a bug related to a phone with a physical key开发者_C百科board, an EditText, and an orientation change.

I don’t have a phone with a physical keyboard, so I have to try to replicate the problem somehow. In the emulator creation screen under the AVD manager in Eclipse, there is an option for “keyboard support.” Is this how I would replicate a physical keyboard phone on the emulator?

Are there any other ways I could debug my problem? Thanks.

Edit upon request: Current symptoms as communicated by the user are

  1. EditText Preference not getting saved (I'm making this assumption based on their input)
  2. Something to due with the activity not switching orientation properly when the user opens up the keypad. It requires the user to open it twice.

Complete Activity code. NOTE: The EditText below is not the problem EditText.

public class GreetingOptions extends PreferenceActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.layout.greeting_options);

        //Set the edit text preference to only accept positive integers
        EditTextPreference fontSize = (EditTextPreference) findPreference("fontSize");
        EditText myEditText = (EditText) fontSize.getEditText();
        myEditText.setKeyListener(DigitsKeyListener.getInstance(false, false));

    }
}


When a user slides out a physical keyboard your app is destroyed and recreated, just the same as what happens when the orientation changes. I would suggest attempting to replicate the problem using an orientation change. You can accomplish this in the emulator using:

Switch to previous layout orientation (for example, portrait, landscape) KEYPAD_7, Ctrl-F11
Switch to next layout orientation (for example, portrait, landscape) KEYPAD_9, Ctrl-F12

To fix the issue I suspect you will need to save the state of your Activity when your app is destroyed and restore it when it is recreated. You may find it useful to review the application lifecycle.

  • Application fundamentals
  • Android emulator


This isn't really an answer, but my experience with the emulator is that its support for any 'physical' inputs is limited to none. Even trying to simulate having a headset plugged in was more than it could handle.

I'd suggest you try to beg, borrow or steal a real phone with a keyboard, and install the app on that.

Sorry I can't be more help :(

0

精彩评论

暂无评论...
验证码 换一张
取 消