简体   繁体   English

当进度对话框正在进行且应用程序的方向发生更改时,Android应用程序崩溃。 为什么?

[英]Android app crash when progress dialog is on progress and app's orientation changed. why?

I have an application in which a progress dialog is shown. 我有一个显示进度对话框的应用程序。 The progress dialog is working properly on any one orientation. 进度对话框可以在任一方向上正常工作。 But when I change the orientation during the progress dialog is on progress mode, then the app crashes. 但是,当我在进度对话框处于进度模式期间更改方向时,该应用程序将崩溃。

So, now how can i fix this problem? 所以,现在我该如何解决这个问题?


Update 更新资料

Hello, Thanks for your answer. 您好,谢谢您的回答。 Here I have extracted the progress dialog code from the whole project and there is no problem. 在这里,我从整个项目中提取了进度对话框代码,没有问题。 You have said to see the Log cat file. 您说过要查看Log cat文件。 But I do not understand the Logcat file. 但我不了解Logcat文件。 Actually what type of error message will be on the Logcat file if the Activity.onCreate() function will create any problem? 如果Activity.onCreate()函数会产生任何问题,实际上Logcat文件上会出现哪种类型的错误消息?

If you have any senario please help me. 如果您有任何问题,请帮助我。

Best Regards, gsmaker 最好的问候,gsmaker

Most chances, this is not the ProgressDialog fault. 大多数情况下,这不是ProgressDialog错误。 Take into an account that Activity.onCreate() is called on every orientation change. 考虑到每次更改方向都会调用Activity.onCreate() In any case, look at LogCat output, you will get more information about the FC. 无论如何,查看LogCat输出,您将获得有关FC的更多信息。

in your AndroidManifest.xml, add in the used activity this: 在您的AndroidManifest.xml中,在使用的活动中添加以下内容:

android:screenOrientation="nosensor" android:configChanges="keyboardHidden|orientation" android:screenOrientation =“ nosensor” android:configChanges =“ keyboardHidden | orientation”

Post the logcat, go to the terminal.. Type the directory /home/xyz/andorid -sdk-xxx/tools 发布logcat,转到终端。键入目录/ home / xyz / andorid -sdk-xxx / tools

once in this directory. 一次在此目录中。 type ./abd logcat 键入./abd logcat

if you are in windows, direct via command prompt to tools directory. 如果您在Windows中,则通过命令提示符直接转到工具目录。 Type adb logcat on command line. 在命令行上键入adb logcat。

do this after you have started the emulator. 启动模拟器后,执行此操作。 Once the emulator is running you will see the logcat printing data every time something happens on ur emulator/device (whatever is running). 模拟器运行后,每次您的模拟器/设备(无论正在运行什么)上发生任何事情时,您都会看到logcat打印数据。

Now change the orientation and you will see data being printed onto the logcat.. When the app crashes, normally a message will be printed... In my advice you copy all that and paste it here, or better, just paste your code here. 现在更改方向,您将看到数据正在打印到logcat上。当应用程序崩溃时,通常会打印一条消息...根据我的建议,您将所有内容复制并粘贴到此处,或者更好的方法是,将代码粘贴到此处。 Only then can we help... 只有这样我们才能帮助...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM