File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 26
26
import java .util .zip .GZIPInputStream ;
27
27
28
28
import processing .data .XML ;
29
+ import android .app .Activity ;
29
30
import android .app .ActivityManager ;
30
31
import android .app .ActivityManager .MemoryInfo ;
31
32
import android .graphics .*;
@@ -147,7 +148,7 @@ protected void allocate() {
147
148
148
149
@ Override
149
150
public void dispose () {
150
- bitmap .recycle ();
151
+ if ( bitmap != null ) bitmap .recycle ();
151
152
}
152
153
153
154
@@ -1089,7 +1090,9 @@ protected void imageImpl(PImage src,
1089
1090
// but I don't think it is particularly efficient, as the bitmaps are stored
1090
1091
// in native heap for Android 10 and older.
1091
1092
MemoryInfo mi = new MemoryInfo ();
1092
- ActivityManager activityManager = (ActivityManager ) parent .getActivity ().getSystemService (android .content .Context .ACTIVITY_SERVICE );
1093
+ Activity activity = parent .getActivity ();
1094
+ if (activity == null ) return ;
1095
+ ActivityManager activityManager = (ActivityManager ) activity .getSystemService (android .content .Context .ACTIVITY_SERVICE );
1093
1096
activityManager .getMemoryInfo (mi );
1094
1097
if (mi .lowMemory ) {
1095
1098
src .bitmap .recycle ();
You can’t perform that action at this time.
0 commit comments