I am trying to test use of GPS in Android, however I am getting java.lang.SecurityException when I try to use the LocationManager object. I know this question has been asked before but I have tried the posted suggestions without any success. Here is the code where the exception is thrown in my OnCreate method of my main Activity which is called GetLocation:
LocationManager locManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); final LocationListener locListener = new MyLocListener(); try{ locManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locListener); } catch (SecurityException se){ ((TextView)findViewById(R.id.infobox)).setText(se.toString()); se.printStackTrace(); } Here is the error I get in logcat: java.lang.SecurityException: Requires ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION permission I know this is typically caused by not including the permissions in my AndroidManifest.xml. However, I already have requested both ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION in the file. Here is my AndroidManifest.xml: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.test.examples" android:versionCode="1" android:versionName="1.0"> <uses-permission android:name="android.permisssion.ACCESS_FINE_LOCATION"></uses- permission> <uses-permission android:name="android.permisssion.ACCESS_COARSE_LOCATION"></uses- permission> <uses-permission android:name="android.permisssion.INTERNET"></ uses-permission> <application android:icon="@drawable/icon" android:label="@string/ app_name"> <activity android:name=".GetLocation" 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> </manifest> This is my first attempt at using permissions so make no assumptions that my environment is configured correctly. I have tried using other permissions in different applications and have seen similar behavior where, even though I request the permission in the AndroidManifest.xml, it doesn't get requested when I install it in the emulator or on my Android phone. Could there be an issue with my eclipse setup? Thanks, Sean -- 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