• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Getting Location In A Service

 
Ranch Hand
Posts: 70
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I wonder if anyone can help me please.  I'm making a simple weather app, the main purpose is to warn me the night before, if the weather will be icy, wet etc overnight or in the morning.

It all works fine in the app itself, parsing the weather info etc, so now I want to make the notification build when the service is called.  I've generally just copied the working code from the app and built it in the notification receiver, but the location isn't being found.

I have this -



In the app this then calls onConnected, but in the service it doesn't.  What do I need to change in the service to get the location just the once?

Thanks
 
Author
Posts: 141
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Andy,
sorry , your problem description is confusing. I don't really know WHAT the problem is here and also - at least for me - I cannot truly parse "it all works fine in the app, ...but the location isn't being found"
 
Andy Crowther
Ranch Hand
Posts: 70
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, when I say 'in the app' I meant in the main activity. If I actually open the app, the above code is in onCreate, the location is found (onConnected is called) and everything works.  When I quit, an alarm is set to call the notification receiver at a set time which contains the same code (as seen above) but when the api is built and called in onReceive, it never calls onConnected.

Does that make sense?  Happy to try again if needed
 
Andy Crowther
Ranch Hand
Posts: 70
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I realise I shouldn't have called it a service either, it's a Notification Receiver.

Also, I had another look and realised I didn't call mGoogleApiClient.connect() at any point...  seems to work now
 
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic