fun subscribeWidgetMenuPosition(){ contentResolver.registerContentObserver( Settings.Secure.getUriFor("wallpaper_menu_x_position"), true, object : ContentObserver(Handler()) { override fun onChange(selfChange: Boolean) { val widgetMenuState = Settings.Secure.getInt(contentResolver, "widget_menu_state") val widgetMenuXPosition = Settings.Secure.getInt(contentResolver, "widget_menu_x_position") Log.i(TAG, "onChange: widget_menu_state=$widgetMenuState, widget_menu_x_position=$widgetMenuXPosition") } }) } 转换为java代码
时间: 2024-02-10 22:18:29 浏览: 44
Here's the Java code equivalent to the given Kotlin code:
```
private void subscribeWidgetMenuPosition() {
getContentResolver().registerContentObserver(
Settings.Secure.getUriFor("wallpaper_menu_x_position"),
true,
new ContentObserver(new Handler()) {
@Override
public void onChange(boolean selfChange) {
int widgetMenuState = Settings.Secure.getInt(
getContentResolver(),
"widget_menu_state"
);
int widgetMenuXPosition = Settings.Secure.getInt(
getContentResolver(),
"widget_menu_x_position"
);
Log.i(TAG, "onChange: widget_menu_state=" + widgetMenuState +
", widget_menu_x_position=" + widgetMenuXPosition);
}
}
);
}
```
阅读全文