问题标签 [activity-finish]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
android - 使用 finish() 的好习惯
我真的是 android 的新手,我创建了一个应用程序,该应用程序具有按钮,这些按钮导致其他活动,在这些活动中,数据被选择通过具有附加功能的意图发送回主要活动。
当我完成数据收集活动时,我调用 finish() 方法返回到我的主要活动。
用户可能希望重新访问信息收集活动以输入新数据,但当他们返回活动时,先前输入的数据是否不存在并不重要。
在编写应用程序时,这被认为是好的还是坏的做法?
谢谢,米
android - 是否可以中断finish()
我有一个以 SingleTask 模式(Android 2.2)运行的活动,它接收来自其他活动或服务的意图。我的活动将每个收到的意图推入队列并对其进行处理。完成后,如果没有任何要处理的意图(即队列为空),它调用finish()。
问题是当它在完成()被调用后立即接收到一个意图时:调用了 onNewIntent 和 onResume 方法,但是我的活动随后被 Android 销毁(onPause/onDestroy)并且未处理该意图。
我知道这是一个非常顽皮的场景,但我对这种行为很感兴趣......所以问题是:是否可以在调用 finish() 后中断 finish() 和/或恢复活动?
谢谢!
ios - 如何知道 NSURLRequest 何时完成加载
我正在实现一个显示一些 Twitter 数据的应用程序,什么时候在 wifi 上工作是可以的,但是在 3g 崩溃时,我得出的结论是,因为获取填充表的数据的 NSURLRequest 需要更长的时间来加载所以表结束当键还没有加载时,调用一个对象作为键,
所以问题是 - 我怎么知道 NSURLRequest 何时完成加载?[我检查了Class Reference,但没有看到它??]
非常感谢!
android - Android: SharedPreference errors after force close
I'm getting some weird effects after I force close my app. When the app is closed with finish(), everything is fine. I have some variables saved in a sharedPreferences so when the app is loaded again, it can restore those variables into the UI. However, if I force close the app and THEN try to continue where it had left off, some variables start "acting funny". By that I mean (in onCreate) I check to see if a string, loaded from the sharedPreferences, equals a value (crunched down version):
What happens here is namec, does in fact, equal "forest". I send the value to the log and it shows the variable exactly as it should be ("forest"). Yet it won't run the code inside of the if{}. It's giving me nightmares. I've been stuck on this for a week!
In the same code, I load a different set of sharedPreferences (labeled as TRHprefs) and each one of those (6 integers and 3 strings) load up and display just fine. I even add an if{} to test 1 string and 1 integer from TRHprefs... they both came back true.
Q.1: Is there anything that can cause my sharedPreferences xml to become, somehow, corrupted on a force close?
Q.2: Is there a way for me to view the xml file before and after I use force close to help debug the situation. Thanks so much!
android - 自“活动B”以来如何完成“活动A”?(自其他完成一项活动)
我正在尝试完成活动 A,因为活动 B 也将完成。活动 B 从活动 A 开始启动。
所以我暂停了活动 A。我该怎么做?
android - 我应该总是先完成一项活动,然后再去另一项活动吗?
您是否总是finish()
在参加另一项活动之前先参加某项活动?
例如,为了防止用户通过手机后退按钮进入上一个活动,有人建议您应该完成除主要活动外的所有活动。这样,后退按钮总是让您返回主要活动(或您认为应该导航用户的任何其他活动)。这是通过覆盖后退按钮行为来完成的。
不好的事情是当 Handler 运行一个对话框,该对话框尝试在活动完成后运行(http://dimitar.me/android-displaying-dialogs-from-background-threads/)。
你在这个问题上的经验法则是什么?以更智能的方式调用finish()
或覆盖后退按钮以将用户引导至您选择的页面?
android - 如何在按下设备上的后退按钮时完成 listActivity
我使用以下代码完成一项活动,但我想在后按事件上完成列表活动。帮助我提前谢谢
android - 替代完成()
我在文档中读到应该避免使用 finish() - 但我真的没有看到更好的选择......
我只是想知道,如果有更好,更清洁的方法来做到这一点......
非常感谢
这是我基本上需要做的:
MainActivity 中的代码:
Sub1Activity 中的代码:
MySMSActivity 中的代码:
android - 如何在android应用程序中实现退出功能
我想在我的 android 应用程序中使用退出功能。有没有办法在按下后退按钮时杀死所有正在运行的活动。实际上,我在单击按钮时显示一个对话框(包含两个按钮),并通过单击对话框上的一个按钮调用另一个活动。但是上一个活动通过它对话框已显示,尚未完成。当我单击对话框的按钮之一时,有什么方法可以完成活动。
我如何使用完成方法来结束上一个活动。这扩展了对话框。
android - android finish() 将返回到哪里
我有一个活动,可以从我的父活动和其他应用程序通过意图过滤器(即 ACTION_VIEW)调用。
当我在我的活动中调用完成()时,如何返回正确的调用者?
即:其他应用程序->我的活动->完成()->其他应用程序
目前,如果我的主要活动仍在运行,finish() 将返回到我的主要活动,尽管它是从其他应用程序调用的。