onaio / kujaku

Mapping and check-in library for Android using MapBox SDK
https://ona.io
BSD 2-Clause "Simplified" License
18 stars 11 forks source link

location permission request callback #287

Closed ferdyrod closed 1 year ago

ferdyrod commented 5 years ago

Hi,

How do I get the permission request result callback on my activity when KujakuMapView checks for permissions? or how can I disabled that the KujakuMapView request permission automatically??

Thanks

ekigamba commented 4 years ago

@ferdyrod Sorry for the late reply. I recently realized that I was my notification settings for this repo were off(I did not have watching ON).

The location request can be enabled by turning off any location features such as the my location button & warm GPS. Any feature that requires the location will request the permission when activitated.

The following are the code examples that enable you disable the warm GPS feature which prompts the location permission as soon as the activity starts

Disable warm GPS feature that starts the location services so that a location is ready whenever needed

You can disable it via XML on the KujakuMapView or in java code after getting the view

  1. Disable using XML view attribute mapbox_warmGps
    ...
       <io.ona.kujaku.views.KujakuMapView
                android:id="@+id/kmv_lowLevelLocationAddPointMapView_mapView"
                android:layout_marginEnd="8dp"
                android:layout_marginLeft="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginStart="8dp"
                android:layout_marginTop="8dp"
                android:minHeight="200dp"
                android:minWidth="200dp"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:mapbox_warmGps="false"

Copied from https://github.com/onaio/kujaku/blob/master/sample/src/main/res/layout/activity_low_level_location_add_point_map_view.xml#L36

  1. Disable in the activity/fragment through a java method call
...
           kujakuMapView = findViewById(R.id.kujakuMapView);
           kujakuMapView.setWarmGps(false)
           kujakuMapView.onCreate(savedInstanceState); 

Disable my location button completely from the view's interface

When this button is clicked, the view tries to start the location services so that it can get a location fix and focus on the user's location

Disable it by

...
        kujakuMapView = findViewById(R.id.kujakuMapView);
        kujakuMapView.showCurrentLocationBtn(false);
        kujakuMapView.onCreate(savedInstanceState);