@cindex volume/multimedia buttons, Android
The volume keys are normally reserved by Emacs and used to provide
the ability to quit Emacs without a physical keyboard
-(@pxref{On-Screen-Keyboards}.) However, if you want them to adjust
+(@pxref{On-Screen Keyboards}.) However, if you want them to adjust
the volume instead, you can set the variable
@code{android-pass-multimedia-buttons-to-system} to a non-@code{nil}
value; note that you will no longer be able to quit Emacs using the
volume buttons in that case.
+@cindex dialog boxes, android
+ Emacs is unable to display dialog boxes (@pxref{Dialog Boxes}) while
+it does not have the input focus on Android 6.0 or later. If this is
+important to you, this ability can be restored by granting Emacs
+permission to display over other programs. Normally, this can be done
+from the:
+
+@indentedblock
+System -> Apps -> Emacs -> More -> Display over other apps
+@end indentedblock
+
+menu in the system settings, but this procedure may vary by device.
+
@node Android Fonts
@section Font backends and selection under Android
@cindex fonts, android
import java.util.ArrayList;
import android.app.AlertDialog;
-import android.content.DialogInterface;
+
import android.content.Context;
+import android.content.DialogInterface;
+
+import android.os.Build;
+
+import android.provider.Settings;
+
import android.util.Log;
import android.widget.Button;
import android.view.View;
import android.view.ViewGroup;
+import android.view.Window;
+import android.view.WindowManager;
/* Toolkit dialog implementation. This object is built from JNI and
describes a single alert dialog. Then, `inflate' turns it into
/* Internal helper for display run on the main thread. */
+ @SuppressWarnings("deprecation")
private boolean
display1 ()
{
- EmacsActivity activity;
- int size;
+ Context context;
+ int size, type;
Button buttonView;
EmacsButton button;
AlertDialog dialog;
+ Window window;
+
+ /* First, try to display a dialog using the service context. */
- if (EmacsActivity.focusedActivities.isEmpty ())
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
+ || Settings.canDrawOverlays (EmacsService.SERVICE))
+ context = EmacsService.SERVICE;
+ else if (EmacsActivity.focusedActivities.isEmpty ())
{
/* If focusedActivities is empty then this dialog may have
been displayed immediately after a popup dialog is
dismissed. */
- activity = EmacsActivity.lastFocusedActivity;
+ context = EmacsActivity.lastFocusedActivity;
- if (activity == null)
+ if (context == null)
return false;
}
else
- activity = EmacsActivity.focusedActivities.get (0);
+ context = EmacsActivity.focusedActivities.get (0);
+
+ Log.d (TAG, "display1: using context " + context);
- dialog = dismissDialog = toAlertDialog (activity);
+ dialog = dismissDialog = toAlertDialog (context);
try
{
+ if (context == EmacsService.SERVICE)
+ {
+ /* Apply the system alert window type to make sure this
+ dialog can be displayed. */
+
+ window = dialog.getWindow ();
+ type = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
+ ? WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
+ : WindowManager.LayoutParams.TYPE_PHONE);
+ window.setType (type);
+ }
+
dismissDialog.show ();
}
catch (Exception exception)