Use file for access token
This commit is contained in:
3
android/java/.gitignore
vendored
3
android/java/.gitignore
vendored
@@ -16,3 +16,6 @@ lib/src/main/assets/
|
||||
|
||||
# Local settings
|
||||
local.properties
|
||||
|
||||
# Token file
|
||||
app/src/main/res/raw/token.txt
|
||||
|
||||
@@ -9,6 +9,10 @@ import android.view.ViewGroup;
|
||||
|
||||
import com.mapbox.mapboxgl.lib.MapView;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public class MapFragment extends Fragment {
|
||||
|
||||
//
|
||||
@@ -39,7 +43,13 @@ public class MapFragment extends Fragment {
|
||||
mMap = (MapView) inflater.inflate(R.layout.fragment_main, container, true);
|
||||
|
||||
// Load the access token
|
||||
mMap.setAccessToken("access token goes here");
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(getActivity().getApplicationContext().getResources().openRawResource(R.raw.token)));
|
||||
String line = reader.readLine();
|
||||
mMap.setAccessToken(line);
|
||||
} catch (IOException e) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
// Need to pass on any saved state to the map
|
||||
mMap.onCreate(savedInstanceState);
|
||||
|
||||
Reference in New Issue
Block a user