如何在Android中的StartActivity其他应用程序之后返回MainActivity?

时间:2015-09-25 04:04:23

标签: android

我想回到RecognitionListener中的MainActivity

onResults(Bundle results) { 
if(results == "go to keep"){
Intent intent = new Intent();
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(new ComponentName("com.google.android.keep", "com.google.android.keep.activities.BrowseActivity"));
startActivity(intent);
}
if(results == "back")
//back to MainActivity
}

1 个答案:

答案 0 :(得分:-1)

您可以在Manifest中将其设置为拥有父级。

请看这里:http://developer.android.com/training/implementing-navigation/ancestral.html

如果您尝试从识别侦听器启动MainActivity,那么您希望执行以下操作:http://developer.android.com/training/basics/firstapp/starting-activity.html