我想在我的 ActionBar 上按钮应用程序中执行
我有详细活动, 这里我可以从家、 最喜爱的和搜索的屏幕中找到。 我也可以从浏览器( 处理特定的 URL) 打开这个屏幕。 当用户按下 Up 按钮时, 我使用 flow () 方法来模仿回溯导航 。 但是, 如果用户来自浏览器, 我想打开家屏幕, 而不是以前的浏览器活动 。 我如何辨别先前的活动来自另一个应用程序, 并浏览到家屏幕?
我想在我的 ActionBar 上按钮应用程序中执行
我有详细活动, 这里我可以从家、 最喜爱的和搜索的屏幕中找到。 我也可以从浏览器( 处理特定的 URL) 打开这个屏幕。 当用户按下 Up 按钮时, 我使用 flow () 方法来模仿回溯导航 。 但是, 如果用户来自浏览器, 我想打开家屏幕, 而不是以前的浏览器活动 。 我如何辨别先前的活动来自另一个应用程序, 并浏览到家屏幕?
向上应总是向活动上级航行,向上应始终向上,向后应始终从时间角度航行。
换句话说,你应该像现在这样离开"回去"
至于Up, 它应该总是去同一个地方, 无论它来自何处。 所以如果通常您从您的 Listactivity 到细节活动, Up应该总是去那里, 无论您从何而来。 最可能的地方由您自行决定, 但是它应该永远是相同的。
如果您从非正常地点( 如浏览器、 其它活动、 部件或通知) 来到“ 细节活动 ”, 您应该重新创建您的任务堆, 从而在导航中使用同一路径的结果。 以下是Android Developmenter training 中的例子 :
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
Intent upIntent = new Intent(this, YourListActivity.class);
if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
// This activity is not part of the application s task, so
// create a new task
// with a synthesized back stack.
TaskStackBuilder
.from(this)
.addNextIntent(new Intent(this, HomeActivity.class))
.addNextIntent(upIntent).startActivities();
finish();
} else {
// This activity is part of the application s task, so simply
// navigate up to the hierarchical parent activity.
NavUtils.navigateUpTo(this, upIntent);
}
return true;
}
}
这是关于实施导航的Android培训
(http://developmenter.android.com/training/ implementing-navigation/index.html )。
您需要 NavUtils 和 TaskStackBuilder 的支持库。
I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...
I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...
I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...
I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...
To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?
When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...
I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...
I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...