|
12 | 12 | import android.content.DialogInterface.OnCancelListener; |
13 | 13 | import android.content.Intent; |
14 | 14 | import android.content.pm.PackageManager; |
| 15 | +import android.content.res.Configuration; |
15 | 16 | import android.content.res.Resources; |
16 | 17 | import android.graphics.Rect; |
17 | 18 | import android.location.Criteria; |
@@ -101,6 +102,7 @@ public class MainActivity extends NativeActivity { |
101 | 102 | System.loadLibrary("smallbasic"); |
102 | 103 | } |
103 | 104 |
|
| 105 | + public static native void onActivityPaused(boolean paused); |
104 | 106 | public static native void onResize(int width, int height); |
105 | 107 | public static native void onUnicodeChar(int ch); |
106 | 108 | public static native boolean optionSelected(int index); |
@@ -378,7 +380,17 @@ public void optionsBox(final String[] items) { |
378 | 380 | this._options = items; |
379 | 381 | runOnUiThread(new Runnable() { |
380 | 382 | public void run() { |
381 | | - openOptionsMenu(); |
| 383 | + invalidateOptionsMenu(); |
| 384 | + Configuration config = getResources().getConfiguration(); |
| 385 | + // https://stackoverflow.com/questions/9996333/openoptionsmenu-function-not-working-in-ics/17903128#17903128 |
| 386 | + if ((config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) > Configuration.SCREENLAYOUT_SIZE_LARGE) { |
| 387 | + int originalScreenLayout = config.screenLayout; |
| 388 | + config.screenLayout = Configuration.SCREENLAYOUT_SIZE_LARGE; |
| 389 | + openOptionsMenu(); |
| 390 | + config.screenLayout = originalScreenLayout; |
| 391 | + } else { |
| 392 | + openOptionsMenu(); |
| 393 | + } |
382 | 394 | } |
383 | 395 | }); |
384 | 396 | } |
@@ -589,6 +601,18 @@ protected void onCreate(Bundle savedInstanceState) { |
589 | 601 | checkFilePermission(); |
590 | 602 | } |
591 | 603 |
|
| 604 | + @Override |
| 605 | + protected void onPause() { |
| 606 | + super.onPause(); |
| 607 | + onActivityPaused(true); |
| 608 | + } |
| 609 | + |
| 610 | + @Override |
| 611 | + protected void onResume() { |
| 612 | + super.onResume(); |
| 613 | + onActivityPaused(false); |
| 614 | + } |
| 615 | + |
592 | 616 | @Override |
593 | 617 | protected void onStop() { |
594 | 618 | super.onStop(); |
|
0 commit comments