WARN/ActivityManager(78): Launch timeout has expir

2019-01-15 17:30发布

问题:

As the title indicates i get this "error" when running my little app:

WARN/ActivityManager(78): Launch timeout has expired, giving up wake lock!

It came after I added this line to my manifest file:

<uses-permission android:name="android.permission.INTERNET" />

The reason I added that line was to get my app the abillity to connect to a serversocket. Read on another forum that the line would solve my problem (not being able to connect). And well it might have but instead I get that other error.

I'm totally new to android so don't understand much of that android specific stuff going on. Have some Java experience though.

Any help appreciated (:

BTW: not sure if I should have posted some of my code?

回答1:

This error means your Activity is taking to long to start. If you are doing a lot of processing on the UI thread, Android kills your application. You should use AsyncTask for any processing intensive stuff.

If you could post your code and your SDK version, I can provide more help. There is also another thread on stackoverflow about this. Activity idle timeout for HistoryRecord?



回答2:

I had a similar problem retrieving a result from a php file in a server. I had solved putting php code inside <html> tags. Without them the app was hanging there.

Hope it helps



回答3:

I had a similar problem.
Inside my View.dispatchDraw(), I was calling a method that triggered another dispatchDraw().
(Adding a logline inside my dispatchDraw() showed that the function was called continuously. This did not show up when doing method profiling in Eclipse)

Hope this is helpful to someone.



回答4:

Check if you don't have 2 or more Eclipse IDEs open (if that is your IDE of choice). It is possible that one of those is taken control over the parts of the ADB and refusing the others access. In my case, I experienced the same error, but when I closed every other Eclipse instance, the app started in debug mode immediately.