Re: [android-developers] Re: When I get gps location in background.I got ANR

2016-03-21 Thread Kai Zhang
Hello, Now I am clear with service.It runs in UI thread.I face a problem that.When I start app in background I start a service in broadcast receiver,then I start a handler thread.But the service gone for seconds,the thread do not execute as normal.Is the service starts from broadcast receiver

Re: [android-developers] Re: When I get gps location in background.I got ANR

2016-03-21 Thread gjs
Hi, Yes - *Caution:* A service runs in the main thread of its hosting process—the service does *not* create its own thread and does *not* run in a separate process (unless you specify otherwise). This means that, if your service is going to do any CPU intensive work or blocking operations

Re: [android-developers] Re: When I get gps location in background.I got ANR

2016-03-20 Thread Kai Zhang
https://github.com/GisKook/testservice 2016-03-20 20:17 GMT+08:00 Kai Zhang : > Hello, > I start a service from broadcast receiver.Then use thread.sleep in > service's onStartCommand function.Then the ANR shows.the code is here( >

Re: [android-developers] Re: When I get gps location in background.I got ANR

2016-03-20 Thread Kai Zhang
Hello, I start a service from broadcast receiver.Then use thread.sleep in service's onStartCommand function.Then the ANR shows.the code is here( https://github.com/GisKook/testservice).So the service is in UI thread too? Thanks, zhangkai 2016-03-20 16:13 GMT+08:00 gjs

[android-developers] Re: When I get gps location in background.I got ANR

2016-03-20 Thread gjs
Hi, ANR usually means you are doing too much work on a UI thread, long running tasks should be run on other non UI threads. Regards On Saturday, March 19, 2016 at 5:43:30 PM UTC+11, Kai Zhang wrote: > > Hello, > I start a service(main service) from broadcast receiver(No 1).I know that > If I