Re: [android-developers] Best practice for co-ordinating a SyncAdapter and GCM updates of data within an app

2013-07-17 Thread TreKing
On Wed, Jul 17, 2013 at 4:51 AM, fr1550n  wrote:

> I'm not sure how to obtain my extended Application instance in the
> SyncAdapter else I'd try and use that.


Context.getApplicationContext().

-
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Best practice for co-ordinating a SyncAdapter and GCM updates of data within an app

2013-07-17 Thread fr1550n
Hiya.
That leads to an error: Cannot make a static reference to the non-static 
method getApplicationContext() from the type Context. 
Also, that call would only obtain the application context which is not the 
same as the Application singleton that, for example, you can obtain from an 
Activity via:
MyApp myApp = (MyApp) getApplication();

On Wednesday, 17 July 2013 17:34:23 UTC+1, TreKing wrote:
>
>
> On Wed, Jul 17, 2013 at 4:51 AM, fr1550n 
> > wrote:
>
>> I'm not sure how to obtain my extended Application instance in the 
>> SyncAdapter else I'd try and use that.
>
>
> Context.getApplicationContext().
>
>
> -
> 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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Best practice for co-ordinating a SyncAdapter and GCM updates of data within an app

2013-07-17 Thread TreKing
On Wed, Jul 17, 2013 at 11:50 AM, fr1550n  wrote:

> That leads to an error: Cannot make a static reference to the non-static
> method getApplicationContext() from the type Context.
>

Well, sure. I was just showing you the class and method you needed.


> Also, that call would only obtain the application context which is not the
> same as the Application singleton
>

Yes it is. Try it. I just did.

-
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Best practice for co-ordinating a SyncAdapter and GCM updates of data within an app

2013-07-18 Thread Shiraz Azizali
Oh, yeah sorry about that :D
I hadn't realised that you can use the application context like that.
So, yes in my onPerformSync I am able to do:
FooApp app = (FooApp) getContext().getApplicationContext();
Thanks, I'm still unsure how to acheive what I'm after from here, but it's
a step forward..


On 17 July 2013 20:56, TreKing  wrote:

>
> On Wed, Jul 17, 2013 at 11:50 AM, fr1550n wrote:
>
>> That leads to an error: Cannot make a static reference to the non-static
>> method getApplicationContext() from the type Context.
>>
>
> Well, sure. I was just showing you the class and method you needed.
>
>
>> Also, that call would only obtain the application context which is not
>> the same as the Application singleton
>>
>
> Yes it is. Try it. I just did.
>
>
> -
> 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 a topic in the
> Google Groups "Android Developers" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/android-developers/KtvZ7D_EKfI/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> android-developers+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [android-developers] Best practice for co-ordinating a SyncAdapter and GCM updates of data within an app

2013-07-18 Thread TreKing
On Thu, Jul 18, 2013 at 3:31 AM, Shiraz Azizali wrote:

> Thanks, I'm still unsure how to acheive what I'm after from here, but it's
> a step forward..
>

A simple static boolean flag should suffice. Each component will run in the
main thread initially to start up. First check the flag, if set, abort the
sync, if not, set it, then proceed with background sync, then reset it when
done.

-
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 unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.