Unsolved Android “gps requires ACCESS_FINE_LOCATION” error
-
As of Android API 23, there is a new way to request location permissions. It doesn't look like QT5.6 beta has been updated to use this method, so I wrote a quick work around. This API 23 change might affect the camera and contacts permissions also, I'm not sure.
Before anyone says, I already have the fine location permission in my manifest:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>Inside your android project, create a template. In the manifest, change:
android:name="org.qtproject.qt5.android.bindings.QtActivity"
to:
android:name="com.my_company.my_project.MyActivity"Create the path inside your android template directory:
src/com/my_company/my_projectNow create the extended activity which requests the permissions as follows:
public class MyActivity extends QtActivity { private static final String[] LOCATION_PERMS={ Manifest.permission.ACCESS_FINE_LOCATION }; private static final int LOCATION_REQUEST = 1337; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Ensure we can run the app if ( !canAccessLocation() ) requestPermissions( LOCATION_PERMS, LOCATION_REQUEST ); } @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { //Figure out what was given to us switch(requestCode) { case LOCATION_REQUEST: if ( canAccessLocation() ) log("Access to location is granted"); else log("Access to location is denied"); break; } } private boolean hasPermission(String perm) { return ( PackageManager.PERMISSION_GRANTED == checkSelfPermission(perm) ); } public boolean canAccessLocation() { return hasPermission(Manifest.permission.ACCESS_FINE_LOCATION); } public static void log( String s ) { Log.d("Radius", s ); } }
This "fix" was taken from the following post:
http://stackoverflow.com/questions/32083913/android-gps-requires-access-fine-location-error-even-though-my-manifest-file -
Hi,
Thanks for sharing your findings. You should also bring that to the Qt Android development mailing list. You'll find there Qt's Android port developers/maintainers. This forum is more user oriented.
-
Thanks for the tip, I'll do that. I'm interested to get in touch with those guys anyway to extend the default implementation of the QML Map library.
-
You're welcome !
Extend it Android wise or globally ?
-
I guess I'll have to see once I get in there. Ideally it would be global.
I'd like to get two finger rotation logic implemented. Also I'd like to change how the zoom works; instead of showing the user a gray square while zooming, I'd rather zoom the best fit tile.