Skip to content

Commit f2b5149

Browse files
committed
修正反射 AppOpsManager 的 OP_POST_NOTIFICATION 字段的方式
1 parent 0093743 commit f2b5149

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

library/src/main/java/com/hjq/toast/ToastStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ protected boolean areNotificationsEnabled(Context context) {
337337
Method method = appOps.getClass().getMethod("checkOpNoThrow",
338338
Integer.TYPE, Integer.TYPE, String.class);
339339
Field field = appOps.getClass().getDeclaredField("OP_POST_NOTIFICATION");
340-
int value = (int) field.get(Integer.class);
340+
int value = field.getInt(null);
341341
return ((int) method.invoke(appOps, value, context.getApplicationInfo().uid,
342342
context.getPackageName())) == AppOpsManager.MODE_ALLOWED;
343343
} catch (NoSuchMethodException | NoSuchFieldException | InvocationTargetException |

0 commit comments

Comments
 (0)