Search code examples
javaandroidandroid-fragmentsandroid-emulatorandroid-preferences

Android Emulator issues with preference activity


I am facing an issue with Android Emulator, I have been already googling a bit about it but I cannot find a valid answer.

I have a simple application in one activity, with swipe view (Fragments being swiped using android.support.v4.view.PagerTabStrip). This is ~ok except some weird swap emulation on API 21 or high screen resulution.

I added a preference activity, triggered with the menu in my main activity:

public boolean onOptionsItemSelected(MenuItem item) {
    ...
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        // start the preference activity
        Intent aIntentPref = new Intent();
        aIntentPref.setClass(MainActivity.this, PrefsActivity.class);
        startActivityForResult(aIntentPref, FC_SETTINGS);
        return true;
    }
    ...
    return super.onOptionsItemSelected(item);
}

My PrefsActivity class is really simple, simply loading a PreferenceFragment, which does only contain one ListPreference so far:

public class PrefsActivity extends PreferenceActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        getFragmentManager().beginTransaction().replace(android.R.id.content,
                new PrefsFragment()).commit();
    }
}

In my device (hdpi API16) or in most of the emulator, it works well. My issue is when I am using an Emulator with API21 (lollipop) or with xxhdpi size (tested with xxhdpi API 19, or any sizes with API21 - even lhdpi), when clicking on the menu item, nothing happen (app stays in MainActivity) but I can see the following in logcat:

1817-1817/{pack} W/EGL_emulation﹕ eglSurfaceAttrib not implemented
1817-1817/{pack} W/InputEventReceiver﹕ Attempted to finish an input event but the input event receiver has already been disposed.
1817-1817/{pack} W/InputEventReceiver﹕ Attempted to finish an input event but the input event receiver has already been disposed.
1817-1817/{pack} W/ViewRootImpl﹕ Dropping event due to root view being removed: MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=115.0, y[0]=76.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=19114, downTime=19114, deviceId=0, source=0x1002 }
  • I tried increasing the emulator memory to 1 GB, it did not help.
  • I tried making the preference menu item always visible, then I could click on it and open the preference activity but any further click on the preference activity had no effect.

Just tested with emulator API 19 - mdpi and it's working fine.

I suspect the emulator is quite bad with high resolution or with API 21, does anyone has further advices on how to fix this or bypass this test issue ? I do not have any device with API 21 with me.

Thanks for those reading up to here ;-)

Edit

With AndroidStudio update, it gets a bit better on some of my android emulator tests, but still the issue is here while testing. I had no bad feedbacks on production version, while running in many devices and APIs. So I guess it's all right and only an emulator issue.


Solution

  • After this long time unanswered, it seems that it is only an issue with emulator as no real issue have been reported.