I don't think that having a locationlistener would switch on the GPS, but I may be mistaken.
On Nov 26, 9:59 pm, crontabpy <[EMAIL PROTECTED]> wrote: > you're right, finally I made it work. > here's the code for who might be in the same issue as > me:http://groups.google.com/group/android-developers/browse_thread/threa... > > But is there any way I decide to turn off or on the Gps? > > I just need to get current location based on an event. > In my point of view, I cant let the listener running, that would mean > GPS will be on all the time and therefor not a good power saving thing > idea. > > How would be a good practice on this? where can I get good information > about this? > > thanks in advance > > On Nov 26, 4:59 pm, Ludwig <[EMAIL PROTECTED]> wrote: > > > You always need a locationlistener in your app, otherwise the GPS updates > > seem not to be recorded. There have been quite a few previous posts on this > > which might be worth reading. > > Ludwig > > > 2008/11/26 crontabpy <[EMAIL PROTECTED]> > > > > hi there, > > > I'm still trying to find out why does loc = > > > locman.getLastKnownLocation("gps"); always returns null value > > > > When I run this app, I telnet to the emulator and enter > > > geo fix 25 25 > > > while the emulator is with my app running. > > > I still get null values. > > > > can anyone help?? > > > > below my app source code: > > > > package com.layout.test; > > > > import android.app.Activity; > > > import android.content.Context; > > > import android.location.Location; > > > import android.location.LocationManager; > > > import android.os.Bundle; > > > import android.view.Menu; > > > import android.view.MenuItem; > > > import android.widget.TextView; > > > > public class Pruebas extends Activity { > > > LocationManager locman = null; > > > Location loc = null; > > > > [EMAIL PROTECTED] > > > public void onCreate(Bundle savedInstanceState) { > > > super.onCreate(savedInstanceState); > > > setContentView(R.layout.main); > > > > } > > > > private void initActivity() { > > > this.locman = (LocationManager) getSystemService > > > (Context.LOCATION_SERVICE); > > > > loc = locman.getLastKnownLocation("gps"); > > > String myString = loc.toString(); > > > TextView text = (TextView) findViewById(R.id.lblTest); > > > text.setText(myString); > > > > } > > > > [EMAIL PROTECTED] > > > public boolean onCreateOptionsMenu(Menu menu) { > > > super.onCreateOptionsMenu(menu); > > > > menu.add(0, 27, 0, "GetLocation").setIcon( > > > android.R.drawable.ic_menu_add); > > > > return true; > > > } > > > > [EMAIL PROTECTED] > > > public boolean onMenuItemSelected(int featureId, MenuItem item) { > > > > switch (item.getItemId()) { > > > case 27: > > > initActivity(); > > > > return true; > > > > } > > > return super.onMenuItemSelected(featureId, item); > > > } > > > } > > > > On Nov 26, 11:33 am, crontabpy <[EMAIL PROTECTED]> wrote: > > > > anyone?having the same problem here > > > > > On Oct 22, 12:29 pm, Matthias <[EMAIL PROTECTED]> wrote: > > > > > > Hi, > > > > > > no, it still doesn't work as expected. It only works when going > > > > > through telnet and sending manual fixes using the geo command, but it > > > > > never works via ADB and Eclipse GUI. Bummer. I run Linux though, and I > > > > > have seen it working on my friend's Windows machine. Is that feature > > > > > platform dependent by any chance? > > > > > > On Oct 16, 8:40 pm, Gautam <[EMAIL PROTECTED]> wrote: > > > > > > > Thanks Ludwig for pointing me in the right direction :) > > > > > > > I've got it working now and this is how it works for me: > > > > > > > For getLastKnownLocation() to work, the best way is to telnet into > > > the > > > > > > emulator geo fix command or DDMS controls using Eclipse. > > > > > > Without using one of these options above to set thelocation, the > > > > > > method will return null. > > > > > > > A better way is to get the LocationAPISample and geo_sample_data > > > fromhttp://groups.google.com/group/android-developers/files > > > > > > > The LocationSample registers a LocationListener so we keep getting > > > > > >locationupdates instead of just onelocationvalue plus the .gpx file > > > > > > can be used to set locations or simulate a path (cool!) > > > > > > > @Matthias > > > > > > Let me know if my pointers help you or we can continue working to > > > > > > get > > > > > > this working for you as well. > > > > > > > Thanks everyone, > > > > > > Gautam > > > > > > > On Oct 16, 1:36 pm, Ludwig <[EMAIL PROTECTED]> wrote: > > > > > > > > There has been a recent exchange over this: > > >http://groups.google.com/group/android-developers/browse_thread/threa... > > > > > > > > Apologies if I missed a more specific problem in your question. > > > > > > > > Ludwig > > > > > > > > 2008/10/16 Matthias <[EMAIL PROTECTED]> > > > > > > > > > anyone found a solution? I am still struggling over this... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

