|
36 | 36 | import android.content.*; |
37 | 37 | import android.content.pm.ActivityInfo; |
38 | 38 | import android.content.pm.ConfigurationInfo; |
| 39 | +import android.content.pm.PackageManager; |
39 | 40 | import android.content.res.AssetManager; |
40 | 41 | import android.content.res.Configuration; |
41 | 42 | import android.graphics.*; |
42 | 43 | import android.net.Uri; |
43 | 44 | import android.opengl.GLSurfaceView; |
44 | 45 | import android.os.Bundle; |
45 | 46 | import android.os.Handler; |
| 47 | +import android.support.v4.content.ContextCompat; |
46 | 48 | //import android.text.format.Time; |
47 | 49 | import android.util.*; |
48 | 50 | import android.view.LayoutInflater; |
@@ -761,16 +763,19 @@ public void resume() { |
761 | 763 |
|
762 | 764 | @Override |
763 | 765 | public void onDestroy() { |
764 | | -// stop(); |
| 766 | + super.onDestroy(); |
765 | 767 | dispose(); |
| 768 | + exit2(); |
766 | 769 | if (PApplet.DEBUG) { |
767 | 770 | System.out.println("PApplet.onDestroy() called"); |
768 | 771 | } |
769 | | - super.onDestroy(); |
770 | | - //finish(); |
771 | 772 | } |
772 | 773 |
|
773 | 774 |
|
| 775 | + public void onPermissionsGranted() { |
| 776 | + |
| 777 | + } |
| 778 | + |
774 | 779 |
|
775 | 780 | ////////////////////////////////////////////////////////////// |
776 | 781 |
|
@@ -1181,6 +1186,11 @@ final public int sketchWindowColor() { |
1181 | 1186 | } |
1182 | 1187 |
|
1183 | 1188 |
|
| 1189 | + public boolean checkPermission(String permission) { |
| 1190 | + int check = ContextCompat.checkSelfPermission(activity, permission); |
| 1191 | + return check == PackageManager.PERMISSION_GRANTED; |
| 1192 | + } |
| 1193 | + |
1184 | 1194 |
|
1185 | 1195 | public void orientation(int which) { |
1186 | 1196 | if (which == PORTRAIT) { |
@@ -3337,7 +3347,10 @@ public void exit() { |
3337 | 3347 |
|
3338 | 3348 | void exit2() { |
3339 | 3349 | try { |
3340 | | - System.exit(0); |
| 3350 | + if (activity != null) { |
| 3351 | + activity.finishAffinity(); |
| 3352 | + } |
| 3353 | +// System.exit(0); |
3341 | 3354 | } catch (SecurityException e) { |
3342 | 3355 | // don't care about applet security exceptions |
3343 | 3356 | } |
@@ -3366,7 +3379,7 @@ final public void dispose() { |
3366 | 3379 | // https://github.com/processing/processing-android/issues/213#issuecomment-217348480 |
3367 | 3380 | surfaceView.getHolder().getSurface().release(); |
3368 | 3381 | surfaceView = null; |
3369 | | - activity = null; |
| 3382 | +// activity = null; |
3370 | 3383 | } |
3371 | 3384 |
|
3372 | 3385 | handleMethods("dispose"); |
|
0 commit comments