gio*_*ozh 1 android background android-activity
我想模拟软Home按钮的行为.我希望当用户点击我的应用程序的特定活动中的后退按钮时,这将进入后台并显示设备主页.我该怎么办(我知道我应该覆盖活动中的onBackPressed())
如果您知道如何覆盖onBackPressed()
然后重写此方法,并在此方法中执行如下操作: -
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助.
归档时间: |
|
查看次数: |
1290 次 |
最近记录: |