- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
当我尝试从后台恢复我的应用程序时,它因 fragment 启动顺序不规则而崩溃。但是如果应用程序从头开始运行,一切都很好。 fragment 结构和日志请见下文。
我目前使用的是常规 fragment ,但支持 fragment 的情况是一样的。 API 27。
<activity android:name=".ActivityMain"
android:theme="@style/AppTheme"
android:screenOrientation="portrait"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustResize">
fragment 结构:
MainActivity
- FragmentProfileBase
- FragmentProfile (child fragment)
设置基础 fragment 函数:
private void setFragment(@NonNull Fragment fragment, @Nullable Bundle bundle){
FragmentTransaction transaction = getFragmentManager().beginTransaction();
fragment.setArguments(bundle);
if (fragmentCurrent != null) {
String classCurrent = fragmentCurrent.getClass().getName();
String classFragment = fragment.getClass().getName();
if (classCurrent.equalsIgnoreCase(classFragment)) {
FragmentBaseAbstract fragmentBaseAbstract = (FragmentBaseAbstract) fragmentCurrent;
fragmentBaseAbstract.setTabClicked();
return;
}
transaction.hide(fragmentCurrent);
}
if (fragment.isAdded())
transaction.show(fragment);
else
transaction.add(R.id.frameContainer, fragment);
transaction.commit();
getFragmentManager().executePendingTransactions();
fragmentCurrent = fragment;
}
设置子 fragment 函数:
public void openFragment(Fragment self, Fragment fragment, boolean removeSelf){
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
if (self != null) {
if (removeSelf)
transaction.remove(self);
transaction.addToBackStack(self.getClass().getName());
}
transaction
.add(getBaseContainer(), fragment)
.setTransition(FragmentTransaction.TRANSIT_NONE);
transaction.commit();
}
常规运行日志:
D/App: onCreate
D/ActivityMain: onCreate
D/FragmentProfileBase: onCreate
D/FragmentProfileBase: onCreateView
D/FragmentProfile: onCreate
D/FragmentProfile: onCreateView
D/FragmentProfile: onCreateOptionsMenu
后台运行日志:
D/App: onCreate
D/FragmentProfile: onCreate actionBar = null
D/FragmentProfileBase: onCreate
D/ActivityMain: onCreate
D/FragmentProfileBase: onCreate
D/FragmentProfileBase: onCreateView
D/FragmentProfile: onCreateView
D/FragmentProfile: onCreate actionBar = android.support.v7.app.ToolbarActionBar@8f9c1fc
D/FragmentProfile: onCreateView
D/FragmentProfileBase: onCreateView
D/FragmentProfile: onCreate actionBar = android.support.v7.app.ToolbarActionBar@8f9c1fc
D/FragmentProfile: onCreateView
完整日志:
02-24 21:21:53.875 9592-9592/? I/zygote64: Late-enabling -Xcheck:jni
02-24 21:21:54.815 9592-9592/com.homework.personalstuff I/MultiDex: VM with version 2.1.0 has multidex support
02-24 21:21:54.815 9592-9592/com.homework.personalstuff I/MultiDex: Installing application
02-24 21:21:54.815 9592-9592/com.homework.personalstuff I/MultiDex: VM has multidex support, MultiDex support library is disabled.
02-24 21:21:54.880 9592-9592/com.homework.personalstuff W/zygote64: Unsupported class loader
02-24 21:21:54.908 9592-9592/com.homework.personalstuff W/zygote64: Skipping duplicate class check due to unsupported classloader
02-24 21:21:54.925 9592-9592/com.homework.personalstuff W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
02-24 21:21:54.931 9592-9592/com.homework.personalstuff W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
02-24 21:21:54.952 9592-9592/com.homework.personalstuff I/BiChannelGoogleApi: [FirebaseAuth: ] No Fallback module; NOT setting up for lazy initialization
02-24 21:21:54.978 9592-9623/com.homework.personalstuff W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
02-24 21:21:54.989 9592-9623/com.homework.personalstuff I/FirebaseAuth: [FirebaseAuth:] Loading module via FirebaseOptions.
02-24 21:21:54.989 9592-9623/com.homework.personalstuff I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
02-24 21:21:55.007 9592-9597/com.homework.personalstuff I/zygote64: Do partial code cache collection, code=30KB, data=20KB
02-24 21:21:55.007 9592-9597/com.homework.personalstuff I/zygote64: After code cache collection, code=30KB, data=20KB
02-24 21:21:55.007 9592-9597/com.homework.personalstuff I/zygote64: Increasing code cache capacity to 128KB
02-24 21:21:55.017 9592-9592/com.homework.personalstuff D/FirebaseAuth: Notifying id token listeners about user ( uH6Bo1NMUOVOIQNiB0pLQswb78l1 ).
02-24 21:21:55.053 9592-9592/com.homework.personalstuff D/FirebaseApp: com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
02-24 21:21:55.139 9592-9592/com.homework.personalstuff V/FA: Registered activity lifecycle callback
02-24 21:21:55.141 9592-9592/com.homework.personalstuff I/FirebaseInitProvider: FirebaseApp initialization successful
02-24 21:21:55.143 9592-9592/com.homework.personalstuff I/InstantRun: starting instant run server: is main process
02-24 21:21:55.166 9592-9627/com.homework.personalstuff V/FA: Collection enabled
02-24 21:21:55.166 9592-9627/com.homework.personalstuff V/FA: App package, google app id: com.homework.personalstuff, 1:633452378895:android:e2b301a85dc1fba2
02-24 21:21:55.168 9592-9627/com.homework.personalstuff I/FA: App measurement is starting up, version: 11910
02-24 21:21:55.168 9592-9627/com.homework.personalstuff I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
02-24 21:21:55.168 9592-9627/com.homework.personalstuff I/FA: To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.homework.personalstuff
02-24 21:21:55.168 9592-9627/com.homework.personalstuff D/FA: Debug-level message logging enabled
02-24 21:21:55.180 9592-9592/com.homework.personalstuff D/App: onCreate
02-24 21:21:55.197 9592-9592/com.homework.personalstuff D/ImageCache: Memory cache created (size = 58982)
02-24 21:21:55.298 9592-9592/com.homework.personalstuff D/ImageCache: Disk cache initialized
02-24 21:21:55.326 9592-9592/com.homework.personalstuff D/UserProfileManager: UserProfileManager
02-24 21:21:55.335 9592-9631/com.homework.personalstuff D/NetworkSecurityConfig: No Network Security Config specified, using platform default
02-24 21:21:55.383 9592-9627/com.homework.personalstuff V/FA: Connecting to remote service
02-24 21:21:55.405 9592-9627/com.homework.personalstuff V/FA: Connection attempt already in progress
02-24 21:21:55.407 9592-9640/com.homework.personalstuff D/Malevich: ImageWorker: HTTP cache initialized
02-24 21:21:55.456 9592-9597/com.homework.personalstuff I/zygote64: Do partial code cache collection, code=61KB, data=43KB
02-24 21:21:55.457 9592-9597/com.homework.personalstuff I/zygote64: After code cache collection, code=58KB, data=42KB
02-24 21:21:55.457 9592-9597/com.homework.personalstuff I/zygote64: Increasing code cache capacity to 256KB
02-24 21:21:55.487 9592-9592/com.homework.personalstuff V/FA: onActivityCreated
02-24 21:21:55.591 9592-9592/com.homework.personalstuff D/FragmentProfile: onCreate
02-24 21:21:55.622 9592-9592/com.homework.personalstuff D/FragmentProfileBase: onCreate
02-24 21:21:55.622 9592-9592/com.homework.personalstuff D/ActivityMain: onCreate
02-24 21:21:55.827 9592-9592/com.homework.personalstuff D/UserProfileManager: checkSignIn
02-24 21:21:55.913 9592-9592/com.homework.personalstuff D/UserProfileManager: checkSignIn prefs facebookIsSignedIn = true
02-24 21:21:55.913 9592-9592/com.homework.personalstuff D/UserProfileManager: checkSignIn firebase getCurrentUser = com.google.firebase.auth.internal.zzh@df479cd
02-24 21:21:55.914 9592-9592/com.homework.personalstuff D/UserProfileManager: dbInitials
02-24 21:21:55.914 9592-9592/com.homework.personalstuff D/UserProfileManager: setDbLastVisited
02-24 21:21:55.954 9592-9592/com.homework.personalstuff D/UserProfileManager: subscribeFriends
02-24 21:21:55.956 9592-9664/com.homework.personalstuff I/DynamiteModule: Considering local module com.google.android.gms.firebase_database:4 and remote module com.google.android.gms.firebase_database:6
02-24 21:21:55.957 9592-9664/com.homework.personalstuff I/DynamiteModule: Selected remote version of com.google.android.gms.firebase_database, version >= 6
02-24 21:21:55.959 9592-9592/com.homework.personalstuff D/UserProfileManager: subscribeProfileChanged
02-24 21:21:55.962 9592-9592/com.homework.personalstuff D/ActivityMain: checkSignIn = true
02-24 21:21:55.969 9592-9592/com.homework.personalstuff D/StuffManager: Create
02-24 21:21:56.018 9592-9664/com.homework.personalstuff W/zygote64: Unsupported class loader
02-24 21:21:56.021 9592-9592/com.homework.personalstuff D/StuffManager: updatePresets
02-24 21:21:56.042 9592-9592/com.homework.personalstuff D/StuffManager: updatePresets listParams = []
02-24 21:21:56.051 9592-9592/com.homework.personalstuff D/SocialManager: Create
02-24 21:21:56.051 9592-9592/com.homework.personalstuff D/ActivityMain: hasExtra type = null
02-24 21:21:56.051 9592-9592/com.homework.personalstuff D/ActivityMain: setFragment
02-24 21:21:56.058 9592-9592/com.homework.personalstuff D/FragmentProfileBase: onCreateView
02-24 21:21:56.060 9592-9592/com.homework.personalstuff D/FragmentProfileBase: openFragment removeSelf true
02-24 21:21:56.062 9592-9592/com.homework.personalstuff D/FragmentProfile: onCreateView
02-24 21:21:56.370 9592-9597/com.homework.personalstuff I/zygote64: Do full code cache collection, code=118KB, data=108KB
02-24 21:21:56.370 9592-9597/com.homework.personalstuff I/zygote64: After code cache collection, code=110KB, data=79KB
02-24 21:21:56.377 9592-9592/com.homework.personalstuff D/FragmentProfile: onCreate
02-24 21:21:56.380 9592-9592/com.homework.personalstuff D/FragmentProfile: onCreateView
02-24 21:21:56.449 9592-9592/com.homework.personalstuff D/FragmentProfileBase: onCreate
02-24 21:21:56.450 9592-9592/com.homework.personalstuff D/FragmentProfileBase: onCreateView
02-24 21:21:56.452 9592-9592/com.homework.personalstuff D/FragmentProfileBase: openFragment removeSelf true
02-24 21:21:56.453 9592-9592/com.homework.personalstuff D/FragmentProfile: onCreate
02-24 21:21:56.454 9592-9592/com.homework.personalstuff D/FragmentProfile: onCreateView
02-24 21:21:56.520 9592-9592/com.homework.personalstuff D/FragmentProfileBase: onStart
02-24 21:21:56.520 9592-9592/com.homework.personalstuff D/FragmentProfile: onStart
02-24 21:21:56.521 9592-9592/com.homework.personalstuff D/AndroidRuntime: Shutting down VM
02-24 21:21:56.525 9592-9592/com.homework.personalstuff E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.homework.personalstuff, PID: 9592
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.homework.personalstuff/com.homework.personalstuff.ActivityMain}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.homework.personalstuff.FragmentProfilePresenter.bindView(com.homework.personalstuff.FragmentProfilePresenter$IFragmentView)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.homework.personalstuff.FragmentProfilePresenter.bindView(com.homework.personalstuff.FragmentProfilePresenter$IFragmentView)' on a null object reference
at com.homework.personalstuff.FragmentProfile.onStart(FragmentProfile.java:133)
at android.support.v4.app.Fragment.performStart(Fragment.java:2287)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1458)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1750)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1819)
at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3227)
at android.support.v4.app.FragmentManagerImpl.dispatchStart(FragmentManager.java:3186)
at android.support.v4.app.Fragment.performStart(Fragment.java:2293)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1458)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1750)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1819)
at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3227)
at android.support.v4.app.FragmentManagerImpl.dispatchStart(FragmentManager.java:3186)
at android.support.v4.app.FragmentController.dispatchStart(FragmentController.java:203)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:582)
at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:177)
at com.homework.personalstuff.ActivityMain.onStart(ActivityMain.java:80)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1334)
at android.app.Activity.performStart(Activity.java:7019)
最佳答案
正如我从您的日志中看到的那样,您正在实现 MVP 架构,因此您需要在使用 fragment 之前将演示者实例注入(inject) fragment 。如果您手动设置演示者 onAttachFragment
Activity 或 fragment 的回调(取决于您的 fragment 托管位置)是执行此操作的好地方。如果你使用依赖注入(inject)onViewCreated
生命周期回调适合注入(inject)。
关于android - 应用无法从后台恢复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48965895/
有什么方法可以恢复删除的元素吗? 这是我删除元素的代码 myFunction() { var width = window.innerWidth; var February = doc
我有一个 TokuDB 表,由于某种原因缺少 ***_status.tokudb 文件。 我还不确定文件是否由于 TokuDB 崩溃而丢失。 问题是: 有没有办法从主要文件和关键文件(我可以从 tok
我正在 Windows 7 (x86) 上运行带有 Workbench 6.3.8 的 32 位 MySQL Server 5.7.22 本地实例(必须选择 32 位版本 - 所以,较旧的版本)。 我
1、备份 <% SQL="backup database 数据库名 to disk='"&Serve
1、ASP中怎么实现SQL数据库备份、恢复! 答:asp在线备份sql server数据库: 1、备份 <% SQL="ba
我在 R 中使用 stats::filter 函数来理解 R 中的 ARIMA 模拟(如在函数 stats::arima.sim 中)和估计。我知道 stats::filter 将线性过滤器应用于向量
我已经浏览了示例应用程序的文档和代码,并发现 files/objectbox/objectbox/data.mdb 是存储所有数据的默认文件。 假设我的理解是正确的,我有几个问题找不到文档: 我想在我
为了恢复非续订订阅类型的 InAppPurchase,我已经实现了服务器来处理此问题。 但在购买过程中,iTunes 有时不会要求用户验证他们的卡详细信息, 在这种情况下,它会在后台发送应用程序并显示
我的问题是寻找cocos2d游戏期间暂停/恢复状态(包括所有需要保存的数据信息)的设计解决方案。 包括但不限于以下情况: 1).用户选择退出,然后弹出一个对话框供用户选择“直接退出”、“暂停”; 2)
在 Mercurial 中,我有一个旧的变更集,除了对单个文件的更改外,它都很好。我将如何恢复对该单个文件的更改? 即使只是能够在上一个变更集中查看文件的状态也会很好,然后我可以剪切和粘贴。 我的 M
我的一项职能遇到了困难。我想做的是计时器在页面加载后立即启动,并且只有一个带有启动/恢复的按钮。我无法在代码中找出需要更改功能的位置。有人可以帮助我吗?谢谢! HTML: , Javascr
我正在阅读Scrap your type classes 。这为类型类提供了替代方案。然而,我被Paul Chiusano的评论所困扰。其中讨论了恢复 do 表示法 语法。 坦白说,我无法理解 ret
当 OrientDB 因某人重新启动机器而非正常关闭时,OrientDB 最终会处于数据恢复失败的状态。对于如何从这种不正常的关闭中正常恢复有什么建议吗?我们正在寻找系统在断电期间能够自行恢复的方法。
我正在构建一个 Electron 应用程序,如果发生崩溃,它必须重新加载渲染进程窗口。 目前我可以从主进程重新启动应用程序 app.relaunch(); app.quit(); 但我无法检测到窗口崩
我有 3 个 Activity ,比如说 MainActivity、 Activity 2 和 Activity 3。 在 MainActivity 中,我有一个按钮(开始/停止),当我单击此按钮时,
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 11 年前。 Improve thi
Twilio 是否支持暂停和恢复内容播放。换句话说,我有相当长的文件将播放给调用者,并且我正在尝试找到一种方法来实现暂停和恢复功能。在播放某些内容的过程中,我希望用户能够按数字暂停,然后再次按数字从音
我已经提交了 A、B、C、D 和 E。我意识到在提交 B 中发生了一些非常糟糕的事情,所以我想回到 A,这次正确地进行之前搞砸了 B 的更改,然后重新应用 C 、 D 和 E 自动。 您可能想知道为什
我的一个文件被“标记为文本”,图标也发生了变化。实际上这是一个 PHP 文件。我尝试过使用 Help -> Find Action -> Mark As 尝试将其恢复为 PHP 突出显示,但它不起作用
我有一些 SSE 程序,可以将循环中的内存归零,当指针未对齐时,它会引发 SIGSEGV进入我的处理程序。我可以在此类处理程序中获取更多信息吗例行公事,现在我不知道它是在哪里完成的,我也可以吗以某种可
我是一名优秀的程序员,十分优秀!