Hey Gandor,

I think you need to add in your androidmanifest.xml

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

normally it goes after the closing application tag

Cheers

On Apr 23, 4:22 pm, gandor <gand...@gmail.com> wrote:
> Hi,
>
> If I want to simulate getspeed using emulator how do I do it.
>
> I used the  following code
> and it gives me
> 04-23 05:39:18.485: ERROR/AndroidRuntime(292): Caused by:
> java.lang.SecurityException: Requires ACCESS_FINE_LOCATION permission
>
> -------------------
>
> package gd.Speedometer;
>
> import android.app.Activity;
> import android.os.Bundle;
> import android.widget.TextView;
> import android.content.Context;
> import android.location.Location;
> import android.location.LocationListener;
> import android.location.LocationManager;
> import android.util.Log;
>
> public class Speedometer extends Activity {
>
>         private TextView tv;
>         private LocationManager lm;
>         private LocationListener ll;
>         double mySpeed, maxSpeed;
>         private final String Speed = null;
>     /** Called when the activity is first created. */
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         Log.i(Speed, "working1 ");
>         super.onCreate(savedInstanceState);
>         tv = new TextView(this);
>         setContentView(tv);
>
>         maxSpeed = mySpeed = 0;
>         Log.i(Speed, "working1 ");
>         lm = (LocationManager) getSystemService
> (Context.LOCATION_SERVICE);
>         ll = new SpeedoActionListener();
>         lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
> ll);
>     }
>
>     private class SpeedoActionListener implements LocationListener
>     {
>
>                 @Override
>                 public void onLocationChanged(Location location) {
>                         Log.i(Speed, "working2 ");
>                         if(location!=null) {
>                                 if(location.hasSpeed()){
>
>                                         mySpeed = location.getSpeed();
>
>                                         tv.setText("\nCurrent speed: "
> + mySpeed + " km/h, Max speed: " +
> maxSpeed + " km/h");
>                                 }
>                         }
>                         Log.i(Speed, "working3 ");
>                 }
>
>                 @Override
>                 public void onProviderDisabled(String provider) {
>                         // TODO Auto-generated method stub
>
>                 }
>
>                 @Override
>                 public void onProviderEnabled(String provider) {
>                         // TODO Auto-generated method stub
>
>                 }
>
>                 @Override
>                 public void onStatusChanged(String provider, int
> status, Bundle
> extras) {
>                         // TODO Auto-generated method stub
>
>                 }
>     }
>
> }

--~--~---------~--~----~------------~-------~--~----~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to