Skip to content

Instantly share code, notes, and snippets.

@TangChr
Last active September 25, 2018 18:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TangChr/3c7077776dcbbf7060c6 to your computer and use it in GitHub Desktop.
Save TangChr/3c7077776dcbbf7060c6 to your computer and use it in GitHub Desktop.
Java: Simulate Home-button in Android
package dk.tcdev.android.gist;
import android.app.Activity;
import android.content.Intent;
public class MyActivity extends Activity {
public void exitApp() {
startActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME));
}
}
@vasyl91
Copy link

vasyl91 commented Sep 25, 2018

I'm always getting following error: Can't create handler inside thread that has not called Looper.prepare()
Any solution? Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment