public void onBackPressed() {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
//intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
/*finish();
System.exit(0);*/
return;
}按下Samsung note 4上的后退按钮,我会看到选择touchwiz launcher或easy mode launcher的选项。我所要做的就是回到默认的启动器。请帮帮我!
发布于 2017-04-12 16:58:47
我找到了这个here
public void onBackPressed() {
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);
}发布于 2017-04-12 16:59:06
您可以尝试使用此命令
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
//getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// app icon in action bar clicked; go home
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
return true;
default:
return super.onOptionsItemSelected(item);
}
}你需要为此启用操作栏(默认情况下,它实际上是启用的,除非手动切换应用程序主题来禁用它),它会根据你的要求将你带到主屏幕上。
将此代码添加到活动的onCreate方法中
ActionBar actionBar = getSupportActionBar();
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.drawable.back_arr);
actionBar.setDisplayShowHomeEnabled(true);R.drawable.back_arr基本上是一个可绘制的箭头图像,当按下它时,您可以在此处使用您自己的图像。
发布于 2017-04-12 17:25:58
尝试重置应用程序首选项
进入设置-> (应用程序|应用程序管理器)->右键菜单,然后选择‘重置应用程序首选项’,将打开一个对话框以确认操作。按YES/OK完成操作。
https://stackoverflow.com/questions/43364763
复制相似问题