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 8
8
import android .graphics .Bitmap ;
9
9
import android .os .Build ;
10
10
import android .os .Bundle ;
11
+ import android .widget .Toast ;
11
12
12
13
import com .mapbox .mapboxandroiddemo .MainActivity ;
13
14
import com .mapbox .mapboxandroiddemo .R ;
24
25
import androidx .annotation .NonNull ;
25
26
import androidx .appcompat .app .AppCompatActivity ;
26
27
import androidx .core .app .NotificationCompat ;
28
+ import timber .log .Timber ;
27
29
28
30
import static android .app .PendingIntent .getActivity ;
29
31
@@ -102,12 +104,18 @@ public void onStyleLoaded(@NonNull Style style) {
102
104
mapSnapshotter .setSize (width , height );
103
105
mapSnapshotter .setRegion (latLngBounds );
104
106
}
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
+ }
111
119
}
112
120
});
113
121
}
Original file line number Diff line number Diff line change 121
121
<!-- Tap on map instruction for toast-->
122
122
<string name =" tap_on_map_instruction" >Tap anywhere on the map</string >
123
123
<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 >
124
125
125
126
<string name =" san_francisco" >San Francisco</string >
126
127
<string name =" los_angeles" >Los Angeles</string >
You can’t perform that action at this time.
0 commit comments