简体   繁体   English

在Android中启动活动时进行异步服务调用

[英]Asynchronous service call while starting the activity in android

I am starting an activity from one by passing some data in the intent. 我正在通过传递一些意图的数据从一个活动开始。 I want the next activity to call some asynchronous service (rest service) with the data from intent and show the result on screen. 我希望下一个活动使用意图中的数据调用一些异步服务(休息服务)并在屏幕上显示结果。

I made the asynchronous call by starting a different thread from onStartup method. 我通过从onStartup方法启动另一个线程进行了异步调用。 But this is failing with below error: 但这失败并显示以下错误:

: INFO/ProductAdvertisingAPIOperation(290): done requesting and parsing
: WARN/ActivityManager(73): Launch timeout has expired, giving up wake lock!
: INFO/Process(290): Sending signal. PID: 290 SIG: 9
: INFO/WindowManager(73): WIN DEATH: Window{43f64a28 com.zzzz.android.xxxx.main/com.zzzz.android.xxxx.main.HomeScreen paused=false}
: INFO/WindowManager(73): WIN DEATH: Window{43ffe9b8 com.zzzz.android.xxxx.main/com.zzzz.android.xxxx.main.CameraView paused=false}
: INFO/UsageStats(73): Unexpected resume of com.android.launcher while already resumed in com.zzzz.android.xxxx.main
: WARN/InputManagerService(73): Got RemoteException sending setActive(false) notification to pid 290 uid 10034

Does anybody know the reason? 有人知道原因吗? Thanks 谢谢

I changed my code to not start the aysnc call in onCreate/onResume/OnStartup. 我更改了代码,以不启动onCreate / onResume / OnStartup中的aysnc调用。 Seems Android has some timeout for UI thread for 5 seconds, beyond which it throws 'Application Not Responding' message. 似乎Android的UI线程超时了5秒钟,超过该时间则抛出“应用程序无响应”消息。 In my case it was failing to load since this was happening on activity startup. 就我而言,它无法加载,因为这是在活动启动时发生的。 So I am calling the async call afte rthe activity is started, onButtonclicked. 因此,在活动开始后,onButtonclicked,我正在调用异步调用。

Thanks Nayn 谢谢内恩

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

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