Android 1.5 和 1.6 调用完成活动和主页按钮后的奇怪行为
Android 平台 1.5
- 我在最后打开启动屏幕,我调用 finish(),然后转到浏览页面。
- 在浏览页面上,当我单击主页按钮时,它会隐藏应用程序。(Android 的多任务功能的 b/c)
- 当我再次转到 Android 的桌面启动应用程序时,它会从启动屏幕启动。
Android 平台 1.6
- 我在最后打开启动屏幕,我调用 finish(),然后转到浏览页面。
- 在浏览页面上,当我单击主页按钮时,它会隐藏应用程序。(Android 的多任务功能的 b/c)
- 当我再次转到 Android 的桌面启动应用程序时,它总是从浏览屏幕而不是启动屏幕启动,这是为什么?
我将所有数据放入 onsave 实例中,
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putString(WLConstants.READ_GPS, readGPS );
outState.putSerializable(WLConstants.SEARCH_CRITERIA, searchCriteria);
outState.putString(WLConstants.PARAM_WHERE, locationField.getText().toString());
outState.putBoolean(WLConstants.PARAM_NEAR_ME, rNearMe.isChecked());
super.onSaveInstanceState(outState);
Log.v(TAG, "onSaveInstanceState()");
}
我从 oncreate 方法中提取值
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(savedInstanceState != null){
Log.v(TAG,"instace found");
}else{
Log.v(TAG,"instace not found");
}
}
“找到实例”从未被调用意味着它永远不会返回捆绑包,为什么?
Android Platform 1.5
- I open splash screen at the end i call finish() then i moved to browse page.
- At the browse page when i click on home button it hide the application.(b/c of Android's Multi tasking feature)
- When i go to Android's desktop launch application again it starts from splash screen.
Android Platform 1.6
- I open splash screen at the end i call finish() then i moved to browse page.
- At the browse page when i click on home button it hide the application.(b/c of Android's Multi tasking feature)
- When i go to Android's desktop launch application again it always starts from browse screen instead of splash screen why is that ?
I am putting all the data in onsave instance
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putString(WLConstants.READ_GPS, readGPS );
outState.putSerializable(WLConstants.SEARCH_CRITERIA, searchCriteria);
outState.putString(WLConstants.PARAM_WHERE, locationField.getText().toString());
outState.putBoolean(WLConstants.PARAM_NEAR_ME, rNearMe.isChecked());
super.onSaveInstanceState(outState);
Log.v(TAG, "onSaveInstanceState()");
}
i am extracting values from oncreate method
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(savedInstanceState != null){
Log.v(TAG,"instace found");
}else{
Log.v(TAG,"instace not found");
}
}
"Instance found" never get called means it never returns bundle any reason why ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚在 1.5 和 1.6 设备上尝试了一个应用程序,该应用程序执行相同的操作 - LAUNCHER 活动是一个启动屏幕,然后启动“主”活动并自行调用
finish()
。启动活动还设置了noHistory
属性。无论如何,在这两种设备上,按“主页”然后再次按启动器图标后,主屏幕按预期显示。
然而,我认为 Android 不提供任何保证,即当您从启动器图标启动进程时,它是否仍处于活动状态。因此,您可以从任务堆栈停止的位置开始,也可以从 LAUNCHER 活动开始。
但就您而言,根据我刚才的经验,当点击启动器时,您通常应该进入“浏览”屏幕。除非你的系统超载得离谱。
无论如何,关于实例状态:您是否尝试过在方法中首先调用
super.onSaveInstanceState(outState)
是否有任何区别?另请注意,该方法通常仅在 Activity 被系统终止时调用;不仅仅是当它进入后台时。在这种情况下,你应该无事可做。
I just tried this with an app on 1.5 and 1.6 devices that does the same thing — the LAUNCHER activity is a splash screen, which then starts the "main" Activity and calls
finish()
on itself. The splash activity also has thenoHistory
attribute set.Anyway, on both devices, the main screen was shown as expected after pressing Home, then the launcher icon again.
I don't think Android provides any guarantees, however, about whether your process will still be alive when you start it from the launcher icon. So you could either start from where your task stack left off, or from the LAUNCHER activity.
But in your case, and in my experience just now, you should generally end up on your "browse" screen when hitting the launcher. Unless your system is ridiculously overloaded.
Anyway, about the instance state: have you tried seeing if calling
super.onSaveInstanceState(outState)
first in the method makes any difference?Also, note that this method is normally only called when the activity is killed off by the system; not just when it goes to the background. There shouldn't be anything for you to do in that case.