-
-
Notifications
You must be signed in to change notification settings - Fork 817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
display pop-up window in foreground and in background #412
Comments
@bmp123 Only in foreground, using Android Permissions API. |
@zoontek I don't found anything about this permissions in android documentation, maybe you can give link? |
Sorry I didn't understand correctly your question at first. A bit more context (and the screenshot) helped. We support Android permissions from the manifest: https://developer.android.com/reference/android/Manifest.permission. If it's not specific to MIUI (Xiaomi OS), it should be in it. |
But if it's specific to MIUI how can I get this permissions programmatically? Maybe you know |
Or these permissions get's only from settings? |
I search for it on internet without any success. I only found https://stackoverflow.com/questions/59645936/displaying-popup-windows-while-running-in-the-background, but there is not code to request the permission directly 😞 |
thank you so much for your answers |
you can directly open other permission screen for MIUI (Xiaomi OS) devices using following code:
but, now problem is how we can check is permission is granted or not ? |
I see that the background pop up window permission is granted by default for apps like Amazon Music and Airbnb. How come that's possible for them? |
Anyone found solution yet? |
I'm gonna have to ask as well: anyone found a solution yet? |
If you download application from Play Store, you application automatically granted SYSTEM_ALERT_WINDOW permission. |
Hi, I found the solution to check if is it granted or not for Xiaomi device's import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.AppOpsManager;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import java.lang.reflect.Method;
// MIUI. Redefining Android.
// (not in the very best way I'd say)
public class XiaomiUtilities {
// custom permissions
public static final int OP_ACCESS_XIAOMI_ACCOUNT = 10015;
public static final int OP_AUTO_START = 10008;
public static final int OP_BACKGROUND_START_ACTIVITY = 10021;
public static final int OP_BLUETOOTH_CHANGE = 10002;
public static final int OP_BOOT_COMPLETED = 10007;
public static final int OP_DATA_CONNECT_CHANGE = 10003;
public static final int OP_DELETE_CALL_LOG = 10013;
public static final int OP_DELETE_CONTACTS = 10012;
public static final int OP_DELETE_MMS = 10011;
public static final int OP_DELETE_SMS = 10010;
public static final int OP_EXACT_ALARM = 10014;
public static final int OP_GET_INSTALLED_APPS = 10022;
public static final int OP_GET_TASKS = 10019;
public static final int OP_INSTALL_SHORTCUT = 10017;
public static final int OP_NFC = 10016;
public static final int OP_NFC_CHANGE = 10009;
public static final int OP_READ_MMS = 10005;
public static final int OP_READ_NOTIFICATION_SMS = 10018;
public static final int OP_SEND_MMS = 10004;
public static final int OP_SERVICE_FOREGROUND = 10023;
public static final int OP_SHOW_WHEN_LOCKED = 10020;
public static final int OP_WIFI_CHANGE = 10001;
public static final int OP_WRITE_MMS = 10006;
public static boolean isMIUI() {
return !TextUtils.isEmpty(getSystemProperty("ro.miui.ui.version.name"));
}
@SuppressLint("PrivateApi")
private static String getSystemProperty(String key) {
try {
Class props = Class.forName("android.os.SystemProperties");
return (String) props.getMethod("get", String.class).invoke(null, key);
} catch (Exception ignore) {
}
return null;
}
@SuppressWarnings("JavaReflectionMemberAccess")
@TargetApi(19)
public static boolean isCustomPermissionGranted(Context context, int permission) {
try {
AppOpsManager mgr = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
Method m = AppOpsManager.class.getMethod("checkOpNoThrow", int.class, int.class, String.class);
int result = (int) m.invoke(mgr, permission, android.os.Process.myUid(), context.getPackageName());
return result == AppOpsManager.MODE_ALLOWED;
} catch (Exception e) {
Logger.INSTANCE.log("XiaomiUtils", e.toString(), Logger.IMPORTANCE.DEFAULT, true);
}
return true;
}
public static Intent getPermissionManagerIntent(Context context) {
Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
intent.putExtra("extra_package_uid", android.os.Process.myUid());
intent.putExtra("extra_pkgname", context.getPackageName());
intent.putExtra("extra_package_name", context.getPackageName());
return intent;
}
} |
did you find out how they get that permission automatically? |
They are white-listed by OEM on MIUI, thats how they got this permission automatically |
Question
is it possible to request xiaomi permissions to display pop-up window in foreground and in background?
The text was updated successfully, but these errors were encountered: