Re: [android-developers] moveTaskToBack(true)

2012-09-04 Thread TreKing
On Tue, Sep 4, 2012 at 12:13 PM, NANI  wrote:

> dont send any messages plzz
>

WTF?

On Tue, Sep 4, 2012 at 12:19 PM, roemer wrote:

> the service doesn't even know if there is a ui... or if there are more
> uis... or what ever the ui is... and of course the ui doesn't maintain the
> state, because the ui maybe doesn't even know all states the service is
> in... but how would the user know what state the service is in...
>
> so thats the problem..
>
> lets say, i pass the service a workload by pressing a button, and
> depending on the button, i change the background color...
> but actually, the service doesn't care about this, the color feedback is
> just for the user... once started, the service does his job
>

This is what I'm saying - you'd have some business object whose
responsibility it is to maintain this state.
You press that button and it sets some variable or something on this
object. When your Activity comes up, it queries this object for the current
state of things and sets up the UI accordingly.

On Tue, Sep 4, 2012 at 12:23 PM, roemer wrote:

> and during the service is working.. it just fires out some updates to who
> ever is listening... i've done this... i've completed that
>
> and according to that, the ui can change further on, in what ever way it
> wants
>

And if no one is listening? (Like the user has closed the Activity showing
the state of things?) This is why you need to maintain that state somewhere
else where you can retrieve it if and when the user closes the Activity and
later comes back to it.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
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
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] moveTaskToBack(true)

2012-09-04 Thread roemer
and during the service is working.. it just fires out some updates to who 
ever is listening... i've done this... i've completed that 

and according to that, the ui can change further on, in what ever way it 
wants

Am Dienstag, 4. September 2012 19:19:38 UTC+2 schrieb roemer:
>
> maybe i explained it bad, both of you are right
>
> of course the service knows in which state it is... the service is running 
> and does some stuff... but due to separation of concern.. the service 
> doesn't even know if there is a ui... or if there are more uis... or what 
> ever the ui is... and of course the ui doesn't maintain the state, because 
> the ui maybe doesn't even know all states the service is in... but how 
> would the user know what state the service is in...
>
> so thats the problem.. as you say, of course the ui shouldn't maintain the 
> state... and neither does it know the state.. it just displays some updates 
> and changes the ui in some certain way...
>
> lets say, i pass the service a workload by pressing a button, and 
> depending on the button, i change the background color... 
> but actually, the service doesn't care about this, the color feedback is 
> just for the user... once started, the service does his job
>
> Am Dienstag, 4. September 2012 19:10:42 UTC+2 schrieb TreKing:
>>
>> On Tue, Sep 4, 2012 at 11:55 AM, Justin Anderson wrote:
>>
>>> there are callbacks to the ui, and recreating the ui while the service 
 is running would mean that i have to maintain a lot of status information 
 in the service, which is actually not the concern of the service at all... 
 it just does its work, and fires some events... which of course don't 
 affect the ui if the activity is finished

>>>
>>> I completely disagree here... In a good OO design the different states 
>>> of the service should be maintained by the service, not by the Activity.  
>>> Maintaining the state of the service anywhere else (like the UI) would lead 
>>> to the service and the UI getting out of sync with one another... As an 
>>> example, the service could be finished but the UI would be out of date and 
>>> say that it is still running.
>>
>>
>> I agree with Justin here. In fact, I'd take it a step further - the logic 
>> and state of whatever the Service is doing would be a completely separate 
>> business object that does the real work and maintains the state or status 
>> of that work. The Service is an Android-specific concept that you employ to 
>> make this object "go". The Activity is an Android-specific concept that you 
>> use to display the status of this business logic to the user.
>>
>> So this object should be doing the bulk of the work and the Service and 
>> Activity should merely be interfacing with it as necessary to accomplish 
>> their own purposes.
>>
>>
>> -
>> TreKing  - Chicago 
>> transit tracking app for Android-powered devices
>>
>>

-- 
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
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] moveTaskToBack(true)

2012-09-04 Thread roemer
maybe i explained it bad, both of you are right

of course the service knows in which state it is... the service is running 
and does some stuff... but due to separation of concern.. the service 
doesn't even know if there is a ui... or if there are more uis... or what 
ever the ui is... and of course the ui doesn't maintain the state, because 
the ui maybe doesn't even know all states the service is in... but how 
would the user know what state the service is in...

so thats the problem.. as you say, of course the ui shouldn't maintain the 
state... and neither does it know the state.. it just displays some updates 
and changes the ui in some certain way...

lets say, i pass the service a workload by pressing a button, and depending 
on the button, i change the background color... 
but actually, the service doesn't care about this, the color feedback is 
just for the user... once started, the service does his job

Am Dienstag, 4. September 2012 19:10:42 UTC+2 schrieb TreKing:
>
> On Tue, Sep 4, 2012 at 11:55 AM, Justin Anderson 
> 
> > wrote:
>
>> there are callbacks to the ui, and recreating the ui while the service is 
>>> running would mean that i have to maintain a lot of status information in 
>>> the service, which is actually not the concern of the service at all... it 
>>> just does its work, and fires some events... which of course don't affect 
>>> the ui if the activity is finished
>>>
>>
>> I completely disagree here... In a good OO design the different states of 
>> the service should be maintained by the service, not by the Activity.  
>> Maintaining the state of the service anywhere else (like the UI) would lead 
>> to the service and the UI getting out of sync with one another... As an 
>> example, the service could be finished but the UI would be out of date and 
>> say that it is still running.
>
>
> I agree with Justin here. In fact, I'd take it a step further - the logic 
> and state of whatever the Service is doing would be a completely separate 
> business object that does the real work and maintains the state or status 
> of that work. The Service is an Android-specific concept that you employ to 
> make this object "go". The Activity is an Android-specific concept that you 
> use to display the status of this business logic to the user.
>
> So this object should be doing the bulk of the work and the Service and 
> Activity should merely be interfacing with it as necessary to accomplish 
> their own purposes.
>
>
> -
> TreKing  - Chicago 
> transit tracking app for Android-powered devices
>
>

-- 
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
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] moveTaskToBack(true)

2012-09-04 Thread Justin Anderson
>
> I agree with Justin here. In fact, I'd take it a step further - the logic
> and state of whatever the Service is doing would be a completely separate
> business object that does the real work and maintains the state or status
> of that work. The Service is an Android-specific concept that you employ to
> make this object "go". The Activity is an Android-specific concept that you
> use to display the status of this business logic to the user.
>
> So this object should be doing the bulk of the work and the Service and
> Activity should merely be interfacing with it as necessary to accomplish
> their own purposes.
>

100% agree!

Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware


On Tue, Sep 4, 2012 at 11:13 AM, NANI  wrote:

> dont send any messages plzz
>
>
> On Tue, Sep 4, 2012 at 10:37 PM, TreKing  wrote:
>
>> On Tue, Sep 4, 2012 at 11:55 AM, Justin Anderson 
>> wrote:
>>
>>> there are callbacks to the ui, and recreating the ui while the service
 is running would mean that i have to maintain a lot of status information
 in the service, which is actually not the concern of the service at all...
 it just does its work, and fires some events... which of course don't
 affect the ui if the activity is finished

>>>
>>> I completely disagree here... In a good OO design the different states
>>> of the service should be maintained by the service, not by the Activity.
>>> Maintaining the state of the service anywhere else (like the UI) would lead
>>> to the service and the UI getting out of sync with one another... As an
>>> example, the service could be finished but the UI would be out of date and
>>> say that it is still running.
>>
>>
>> I agree with Justin here. In fact, I'd take it a step further - the logic
>> and state of whatever the Service is doing would be a completely separate
>> business object that does the real work and maintains the state or status
>> of that work. The Service is an Android-specific concept that you employ to
>> make this object "go". The Activity is an Android-specific concept that you
>> use to display the status of this business logic to the user.
>>
>> So this object should be doing the bulk of the work and the Service and
>> Activity should merely be interfacing with it as necessary to accomplish
>> their own purposes.
>>
>>
>> -
>> TreKing  - Chicago
>> transit tracking app for Android-powered devices
>>
>>  --
>> 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
>> To unsubscribe from this group, send email to
>> android-developers+unsubscr...@googlegroups.com
>> 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 android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] moveTaskToBack(true)

2012-09-04 Thread NANI
dont send any messages plzz


On Tue, Sep 4, 2012 at 10:37 PM, TreKing  wrote:

> On Tue, Sep 4, 2012 at 11:55 AM, Justin Anderson wrote:
>
>> there are callbacks to the ui, and recreating the ui while the service is
>>> running would mean that i have to maintain a lot of status information in
>>> the service, which is actually not the concern of the service at all... it
>>> just does its work, and fires some events... which of course don't affect
>>> the ui if the activity is finished
>>>
>>
>> I completely disagree here... In a good OO design the different states of
>> the service should be maintained by the service, not by the Activity.
>> Maintaining the state of the service anywhere else (like the UI) would lead
>> to the service and the UI getting out of sync with one another... As an
>> example, the service could be finished but the UI would be out of date and
>> say that it is still running.
>
>
> I agree with Justin here. In fact, I'd take it a step further - the logic
> and state of whatever the Service is doing would be a completely separate
> business object that does the real work and maintains the state or status
> of that work. The Service is an Android-specific concept that you employ to
> make this object "go". The Activity is an Android-specific concept that you
> use to display the status of this business logic to the user.
>
> So this object should be doing the bulk of the work and the Service and
> Activity should merely be interfacing with it as necessary to accomplish
> their own purposes.
>
>
> -
> TreKing  - Chicago
> transit tracking app for Android-powered devices
>
>  --
> 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
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] moveTaskToBack(true)

2012-09-04 Thread TreKing
On Tue, Sep 4, 2012 at 11:55 AM, Justin Anderson wrote:

> there are callbacks to the ui, and recreating the ui while the service is
>> running would mean that i have to maintain a lot of status information in
>> the service, which is actually not the concern of the service at all... it
>> just does its work, and fires some events... which of course don't affect
>> the ui if the activity is finished
>>
>
> I completely disagree here... In a good OO design the different states of
> the service should be maintained by the service, not by the Activity.
> Maintaining the state of the service anywhere else (like the UI) would lead
> to the service and the UI getting out of sync with one another... As an
> example, the service could be finished but the UI would be out of date and
> say that it is still running.


I agree with Justin here. In fact, I'd take it a step further - the logic
and state of whatever the Service is doing would be a completely separate
business object that does the real work and maintains the state or status
of that work. The Service is an Android-specific concept that you employ to
make this object "go". The Activity is an Android-specific concept that you
use to display the status of this business logic to the user.

So this object should be doing the bulk of the work and the Service and
Activity should merely be interfacing with it as necessary to accomplish
their own purposes.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
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
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] moveTaskToBack(true)

2012-09-04 Thread Justin Anderson
>
> there are callbacks to the ui, and recreating the ui while the service is
> running would mean that i have to maintain a lot of status information in
> the service, which is actually not the concern of the service at all... it
> just does its work, and fires some events... which of course don't affect
> the ui if the activity is finished
>

I completely disagree here... In a good OO design the different states of
the service should be maintained by the service, not by the Activity.
Maintaining the state of the service anywhere else (like the UI) would lead
to the service and the UI getting out of sync with one another... As an
example, the service could be finished but the UI would be out of date and
say that it is still running.

Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware


On Tue, Sep 4, 2012 at 10:49 AM, roemer wrote:

> there are callbacks to the ui, and recreating the ui while the service is
> running would mean that i have to maintain a lot of status information in
> the service, which is actually not the concern of the service at all... it
> just does its work, and fires some events... which of course don't affect
> the ui if the activity is finished

-- 
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
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] moveTaskToBack(true)

2012-09-04 Thread roemer
hm... I see what you mean, but I don't like this thought...

there are callbacks to the ui, and recreating the ui while the service is 
running would mean that i have to maintain a lot of status information in 
the service, which is actually not the concern of the service at all... it 
just does its work, and fires some events... which of course don't affect 
the ui if the activity is finished

the whole android activity stack and life cycle is that flexible, that you 
end up programming each possibility you come to your activity (oncreate, 
onresume, onnewintent, onactivityresult ), which gets more and more  
laborious I think... 

but you are probably right.. recreate it and store important data in 
preferences or so...

Am Dienstag, 4. September 2012 18:13:44 UTC+2 schrieb TreKing:
>
> On Tue, Sep 4, 2012 at 7:30 AM, roemer 
> > wrote:
>
>> Any ideas on what could probably cause the problem?
>
>
> You have the source code ... step through and see.
>
> Besides that, I don't think this is what you should be doing anyway. The 
> fact that this Activity is the UI for a Service does not make it special. 
> Let it live and die as normal, binding and unbinding from the Service as 
> necessary, through its lifecycle.
>
>
> -
> TreKing  - Chicago 
> transit tracking app for Android-powered devices
>
>

-- 
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
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] moveTaskToBack(true)

2012-09-04 Thread TreKing
On Tue, Sep 4, 2012 at 7:30 AM, roemer wrote:

> Any ideas on what could probably cause the problem?


You have the source code ... step through and see.

Besides that, I don't think this is what you should be doing anyway. The
fact that this Activity is the UI for a Service does not make it special.
Let it live and die as normal, binding and unbinding from the Service as
necessary, through its lifecycle.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
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
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] moveTaskToBack(true)

2012-09-04 Thread roemer
Hi all!

I have a singleTask activity which contains the UI for a long running 
background service.
If the service is currently active and doing something and the user presses 
the back button, It is certain, that the user will return to the activity 
later.

So I wrote:

@Override

public void onBackPressed() {

if(!isWorking())

super.onBackPressed();

else {

moveTaskToBack(true);

}

}


The problem is, that moveTaskToBack always returns false, and nothing 
happens on that call.

Any ideas on what could probably cause the problem?

cheers!

-- 
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
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en