I follow the GPS tutorial for SDK 1.0 but...

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

I follow the GPS tutorial for SDK 1.0 but...

Postby salemar86 » Sun Dec 07, 2008 5:07 pm

I've followed the tutorial at http://www.devx.com/wireless/Article/39239/1954 for using GPS, but when I try to send to the emulator GPS information (manually, with kml or gpx) nothing happens...
Can you help me?
Thanks a lot...

This is my code:


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. import android.app.Activity;
  2.  
  3. import android.content.Context;
  4.  
  5. import android.location.Location;
  6.  
  7. import android.location.LocationListener;
  8.  
  9. import android.location.LocationManager;
  10.  
  11. import android.os.Bundle;
  12.  
  13. import android.widget.Toast;
  14.  
  15.  
  16.  
  17. public class GPS3 extends Activity {
  18.  
  19.         public class GPS extends Activity
  20.  
  21.         {
  22.  
  23.             private LocationManager lm;
  24.  
  25.             private LocationListener locationListener;
  26.  
  27.  
  28.  
  29.             /** Called when the activity is first created. */
  30.  
  31.             @Override
  32.  
  33.             public void onCreate(Bundle savedInstanceState) {
  34.  
  35.                 super.onCreate(savedInstanceState);
  36.  
  37.                 setContentView(R.layout.main);
  38.  
  39.                
  40.  
  41.                 //---use the LocationManager class to obtain GPS locations---
  42.  
  43.                 lm = (LocationManager)
  44.  
  45.                     getSystemService(Context.LOCATION_SERVICE);    
  46.  
  47.                
  48.  
  49.                 locationListener = new MyLocationListener();
  50.  
  51.                
  52.  
  53.                 lm.requestLocationUpdates(
  54.  
  55.                     LocationManager.GPS_PROVIDER,
  56.  
  57.                     0,
  58.  
  59.                     0,
  60.  
  61.                     locationListener);        
  62.  
  63.             }
  64.  
  65.            
  66.  
  67.             private class MyLocationListener implements LocationListener
  68.  
  69.             {
  70.  
  71.                
  72.  
  73.  
  74.  
  75.                 @Override
  76.  
  77.                 public void onProviderDisabled(String provider) {
  78.  
  79.                     // TODO Auto-generated method stub
  80.  
  81.                 }
  82.  
  83.  
  84.  
  85.                 @Override
  86.  
  87.                 public void onProviderEnabled(String provider) {
  88.  
  89.                     // TODO Auto-generated method stub
  90.  
  91.                 }
  92.  
  93.  
  94.  
  95.                 @Override
  96.  
  97.                 public void onStatusChanged(String provider, int status,
  98.  
  99.                     Bundle extras) {
  100.  
  101.                     // TODO Auto-generated method stub
  102.  
  103.                 }
  104.  
  105.  
  106.  
  107.                         @Override
  108.  
  109.                         public void onLocationChanged(Location location) {
  110.  
  111.                                   if (location != null) {
  112.  
  113.                                 Toast.makeText(getBaseContext(),
  114.  
  115.                                     "Location changed : Lat: " + location.getLatitude() +
  116.  
  117.                                     " Lng: " + location.getLongitude(),
  118.  
  119.                                     Toast.LENGTH_SHORT).show();
  120.  
  121.                             }
  122.  
  123.                                
  124.  
  125.                         }
  126.  
  127.             }        
  128.  
  129.            
  130.  
  131.         }
  132.  
  133.        
  134.  
  135. }
Parsed in 0.038 seconds, using GeSHi 1.0.8.4



Main Layout

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  4.  
  5.    android:orientation="vertical"
  6.  
  7.    android:layout_width="fill_parent"
  8.  
  9.    android:layout_height="fill_parent"
  10.  
  11.    >
  12.  
  13. </LinearLayout>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


Manifest

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  4.  
  5.      package="com.alex"
  6.  
  7.      android:versionCode="1"
  8.  
  9.      android:versionName="1.0.0">
  10.  
  11.      
  12.  
  13.      
  14.  
  15.      
  16.  
  17.     <application android:icon="@drawable/icon" android:label="@string/app_name">
  18.  
  19.         <activity android:name=".GPS3"
  20.  
  21.                  android:label="@string/app_name">
  22.  
  23.             <intent-filter>
  24.  
  25.                 <action android:name="android.intent.action.MAIN" />
  26.  
  27.                 <category android:name="android.intent.category.LAUNCHER" />
  28.  
  29.             </intent-filter>
  30.  
  31.         </activity>
  32.  
  33.     </application>
  34.  
  35. <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
  36.  
  37. <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"></uses-permission>
  38.  
  39.  
  40.  
  41. </manifest>
Parsed in 0.003 seconds, using GeSHi 1.0.8.4
salemar86
Freshman
Freshman
 
Posts: 5
Joined: Sat Nov 29, 2008 5:50 pm

Top

Anyone!

Postby k2thedevil » Mon Feb 02, 2009 3:54 am

Im having similar issues. Can someone please help us out?
Bug Out!
k2thedevil
Freshman
Freshman
 
Posts: 4
Joined: Fri Jan 30, 2009 9:46 pm

Re: Anyone!

Postby bose pandian » Mon Feb 16, 2009 12:57 pm

k2thedevil wrote:Im having similar issues. Can someone please help us out?


In Eclipse

1. Go to the DDMS Mode and select the Emulator Control.

Or, select the Emulator from the Eclipse

window-> show view -> others -> Emulator Control.

Here, in the manual tag, give the longitude and latitude for any country and click the "send" button.
Now you will see the emulator, it changes map to the given latitude and longitude.

I think this helps you to solves the problem..

Regards,
Bose.C
bose pandian
Junior Developer
Junior Developer
 
Posts: 23
Joined: Tue Dec 30, 2008 3:46 pm
Location: bangalore

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 3 guests