#2018 - Adding basic second activity that displays a map

This commit is contained in:
Brad Leege
2015-09-15 14:07:24 -04:00
parent a3ea4acb7c
commit 2ae0fbeec4
11 changed files with 120 additions and 11 deletions

View File

@@ -17,6 +17,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SecondMapActivity"/>
<meta-data
android:name="io.fabric.ApiKey"
android:value="9724157045ff7d083492c6d9ae03e60e8609d461" />

View File

@@ -1,6 +1,7 @@
package com.mapbox.mapboxgl.testapp;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.graphics.PointF;
@@ -281,6 +282,10 @@ public class MainActivity extends AppCompatActivity {
menuItem.setChecked(mMapView.isCompassEnabled());
return true;
case R.id.action_second_map_activity:
startActivity(new Intent(getApplicationContext(), SecondMapActivity.class));
return true;
/*
case R.id.followNone:
mMapView.setUserLocationTrackingMode(MapView.UserLocationTrackingMode.NONE);

View File

@@ -0,0 +1,83 @@
package com.mapbox.mapboxgl.testapp;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import com.mapbox.mapboxgl.views.MapView;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class SecondMapActivity extends AppCompatActivity {
private static final String TAG = "SecondMapActivity";
private MapView mMapView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
mMapView = (MapView) findViewById(R.id.secondMapView);
// Load the access token
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(getResources().openRawResource(R.raw.token)));
String line = reader.readLine();
mMapView.setAccessToken(line);
} catch (IOException e) {
Log.e(TAG, "Error loading access token from token.txt: " + e.toString());
}
mMapView.onCreate(savedInstanceState);
mMapView.setStyleUrl(getString(R.string.styleURLMapboxStreets));
}
/**
* Dispatch onStart() to all fragments. Ensure any created loaders are
* now started.
*/
@Override
protected void onStart() {
super.onStart();
mMapView.onStart();
}
@Override
protected void onStop() {
super.onStop();
mMapView.onStop();
}
// Called when our app goes into the background
@Override
public void onPause() {
super.onPause();
mMapView.onPause();
}
// Called when our app comes into the foreground
@Override
public void onResume() {
super.onResume();
mMapView.onResume();
}
@Override
protected void onDestroy() {
super.onDestroy();
mMapView.onDestroy();
}
// Called when the system is running low on memory
@Override
public void onLowMemory() {
super.onLowMemory();
mMapView.onLowMemory();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 B

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mapbox.mapboxgl.views.MapView
android:id="@+id/secondMapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>

View File

@@ -19,18 +19,24 @@
android:checkable="true"
/>
<!--
<group android:id="@+id/locationFollowModesSeparator"/>
<item android:id="@+id/action_second_map_activity"
android:icon="@drawable/ic_looks_two_white_24dp"
android:title="@string/action_second_map_activity"
android:checkable="true"
/>
<group android:id="@+id/locationFollowModes" android:checkableBehavior="single">
<item android:id="@+id/followNone"
android:title="@string/action_location_none"/>
<item android:id="@+id/followFollow"
android:title="@string/action_location_follow"/>
<item android:id="@+id/followBearing"
android:title="@string/action_location_bearing"/>
</group>
-->
<!--
<group android:id="@+id/locationFollowModesSeparator"/>
<group android:id="@+id/locationFollowModes" android:checkableBehavior="single">
<item android:id="@+id/followNone"
android:title="@string/action_location_none"/>
<item android:id="@+id/followFollow"
android:title="@string/action_location_follow"/>
<item android:id="@+id/followBearing"
android:title="@string/action_location_bearing"/>
</group>
-->
<group android:id="@+id/stylesSeparator"/>

View File

@@ -10,6 +10,7 @@
<string name="action_compass">Toggle compass</string>
<string name="action_debug">Toggle debug mode</string>
<string name="action_point_annotations">Toggle point annotations</string>
<string name="action_second_map_activity">Launch 2nd Map</string>
<string name="label_fps">FPS:</string>