Example how to not losing asynctask state when rotate screen

Categories: ANDROID like

public class MainActivity extends AppCompatActivity { private Async task; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); task = (Async) getLastCustomNonConfigurationInstance(); if (task == null) { task = new Async(this); task.execute(); } else { task.attach(this); } } @Override public Object onRetainCustomNonConfigurationInstance() { task.detach(); return task; } private static class Async extends AsyncTask<Void, Void, Void> { […]

TIL: awake and unlock screen when installing app is possible

Categories: ANDROID like

Here is the link: http://stackoverflow.com/questions/22332513/wake-and-unlock-android-phone-screen-when-compile-and-run-project Here is the answer: One solution: set the following flags in your activity class(es): if (BuildConfig.DEBUG) { // These flags cause the device screen to turn on (and bypass screen guard if possible) when launching. // This makes it easy for developers to test the app launch without needing to […]