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; > > @Override > 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); > > > } > > @Override > public boolean onCreateOptionsMenu(Menu menu) { > super.onCreateOptionsMenu(menu); > > menu.add(0, 27, 0, "GetLocation").setIcon( > android.R.drawable.ic_menu_add); > > > return true; > } > > @Override > 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 android-developers@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---