Use file for access token

This commit is contained in:
Leith Bade
2014-12-18 19:29:55 +11:00
parent 62038bb344
commit 465ae587a2
4 changed files with 23 additions and 10 deletions

View File

@@ -16,3 +16,6 @@ lib/src/main/assets/
# Local settings
local.properties
# Token file
app/src/main/res/raw/token.txt

View File

@@ -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);