Hello everybody,

                     I use the following code to play with gps. In
emulator its working with sending manually gps data
but in real phone when i installed it only showing the gps icon but no
data is coming.I am not able to understand whats wrong in this code.
In real phone I enable Gps and in Map application I can able to see my
current Location.

Here is the Java code :

import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.Toast;

public class UseGps extends Activity
{

        /** Called when the activity is first created. */

        @Override
        public void onCreate(Bundle savedInstanceState)
        {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
                /* Use the LocationManager class to obtain GPS locations */
                LocationManager mlocManager =
(LocationManager)getSystemService(Context.LOCATION_SERVICE);
                LocationListener mlocListener = new MyLocationListener();
                mlocManager.requestLocationUpdates( 
LocationManager.GPS_PROVIDER, 0,
0, mlocListener);
        }
        /* Class My Location Listener */
        public class MyLocationListener implements LocationListener
        {

                public void onLocationChanged(Location loc)
                {
                        loc.getLatitude();
                        loc.getLongitude();
                        String Text = "My current location is: " + "Latitud = " 
+
loc.getLatitude() + "Longitud = " + loc.getLongitude();
        
Toast.makeText( getApplicationContext(),Text,Toast.LENGTH_SHORT).show();
                }
                public void onProviderDisabled(String provider)
                {
                        Toast.makeText( getApplicationContext(),"Gps
Disabled",Toast.LENGTH_SHORT ).show();
                }
                public void onProviderEnabled(String provider)
                {
                        Toast.makeText( getApplicationContext(),"Gps
Enabled",Toast.LENGTH_SHORT).show();
                }
                public void onStatusChanged(String provider, int status, Bundle
extras)
                {

                }

        }

}




Here is the Manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android";
      package="com.android.location1"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/
app_name">
        <activity android:name=".UseGps"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
    <uses-sdk android:minSdkVersion="3" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"> </uses-
permission>
</manifest>










Thanks & regards
Arindam Ghosh

-- 
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

Reply via email to