I never said anything about a background thread.
Assuming a service, just replace this:
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
..... blah blah.... make some objects, call some methods...
return START_...;
}
With this:
@Override
public int onStartCommand(final Intent intent, final int flags, final int
startId) {
new Handler().post(new Runnable() {
@Override
public void run() {
..... blah blah.... make some objects, call some methods...
}});
return START_...;
}
... might want to save the handler object somewhere for reuse, I'm not
typing that here for brevity.
... might be useful to use the recently added BuildConfig.DEBUG and switch
the two code paths automatically.
-- K
28 апреля 2012 г. 18:50 пользователь Streets Of Boston <
[email protected]> написал:
> Not entirely possible. I already offloaded quite a bit of processing on a
> background thread Handler, but some of the code MUST run on the main (UI)
> thread (the service inflates a View with a WebView used for HTML
> pre-rendering).
>
>
> On Friday, April 27, 2012 6:10:31 PM UTC-4, Kostya Vasilyev wrote:
>
>> Make a Handler and post the processing logic to it as a runnable.
>>
>> You will still get the ANR which you can ignore, but the process won't be
>> killed.
>>
>> -- K
>>
>> 28 апреля 2012 г. 1:09 пользователь Justin Anderson написал:
>>
>>> AFAIK there isn't... But if I'm wrong, I would love for someone to point
>>> out how to do it as well!
>>>
>>> Thanks,
>>> Justin Anderson
>>> MagouyaWare Developer
>>> http://sites.google.com/site/**magouyaware<http://sites.google.com/site/magouyaware>
>>>
>>>
>>>
>>> On Fri, Apr 27, 2012 at 2:46 PM, Streets Of Boston wrote:
>>>
>>> I'm debugging on a device.
>>>>
>>>> When setting a breakpoint in a process that runs a Service or a
>>>> BroadcastReceiver on a spot in the code that is run on the main (UI)
>>>> thread, the phone's watch-dog service kills the process, because I'm
>>>> stepping through the code slowly.
>>>>
>>>> Is there a way, when in debug-mode, to stop the watch-dog service from
>>>> killing the process that i'm debugging?
>>>> It is very annoying when this happens or any debugging must be done
>>>> very quickly (no more that 10 seconds total).
>>>>
>>>> Thanks!
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Android Developers" group.
>>>> To post to this group, send email to android-developers@**
>>>> googlegroups.com <[email protected]>
>>>> To unsubscribe from this group, send email to
>>>> android-developers+**[email protected]<android-developers%[email protected]>
>>>> For more options, visit this group at
>>>> http://groups.google.com/**group/android-developers?hl=en<http://groups.google.com/group/android-developers?hl=en>
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Android Developers" group.
>>> To post to this group, send email to android-developers@**
>>> googlegroups.com <[email protected]>
>>> To unsubscribe from this group, send email to
>>> android-developers+**[email protected]<android-developers%[email protected]>
>>> For more options, visit this group at
>>> http://groups.google.com/**group/android-developers?hl=en<http://groups.google.com/group/android-developers?hl=en>
>>>
>>
>> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en