This repository was archived by the owner on Oct 7, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed
MapboxAndroidDemo/src/main
java/com/mapbox/mapboxandroiddemo/examples/snapshot Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 88import android .graphics .Bitmap ;
99import android .os .Build ;
1010import android .os .Bundle ;
11+ import android .widget .Toast ;
1112
1213import com .mapbox .mapboxandroiddemo .MainActivity ;
1314import com .mapbox .mapboxandroiddemo .R ;
2425import androidx .annotation .NonNull ;
2526import androidx .appcompat .app .AppCompatActivity ;
2627import androidx .core .app .NotificationCompat ;
28+ import timber .log .Timber ;
2729
2830import static android .app .PendingIntent .getActivity ;
2931
@@ -102,12 +104,18 @@ public void onStyleLoaded(@NonNull Style style) {
102104 mapSnapshotter .setSize (width , height );
103105 mapSnapshotter .setRegion (latLngBounds );
104106 }
105- mapSnapshotter .start (new MapSnapshotter .SnapshotReadyCallback () {
106- @ Override
107- public void onSnapshotReady (MapSnapshot snapshot ) {
108- createNotification (snapshot .getBitmap ());
109- }
110- });
107+ try {
108+ mapSnapshotter .start (new MapSnapshotter .SnapshotReadyCallback () {
109+ @ Override
110+ public void onSnapshotReady (MapSnapshot snapshot ) {
111+ createNotification (snapshot .getBitmap ());
112+ }
113+ });
114+ } catch (IllegalStateException exception ) {
115+ Timber .d (exception );
116+ Toast .makeText (SnapshotNotificationActivity .this ,
117+ R .string .snapshotter_was_already_started , Toast .LENGTH_SHORT ).show ();
118+ }
111119 }
112120 });
113121 }
Original file line number Diff line number Diff line change 121121 <!-- Tap on map instruction for toast-->
122122 <string name =" tap_on_map_instruction" >Tap anywhere on the map</string >
123123 <string name =" tap_on_map_for_notification" >Tap on map to get a notification with map image</string >
124+ <string name =" snapshotter_was_already_started" >Snapshotter was already started</string >
124125
125126 <string name =" san_francisco" >San Francisco</string >
126127 <string name =" los_angeles" >Los Angeles</string >
You can’t perform that action at this time.
0 commit comments