我有一个实现OnSharedPreferenceChangeListener的var express = require('express');
var app = express();
var server = require('http').Server(app);
var io = require('socket.io')(server);
server.listen(80);
app.use(express.static(__dirname));
类。
Example
但是,当我在托管片段的public class Example implements SharedPreferences.OnSharedPreferenceChangeListener {
public Example(Context cont) {
this.context = cont;
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(cont);
sharedPref.registerOnSharedPreferenceChangeListener(this);
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
Log.d("TAG", "A preference has changed >>" + key);
}
}
中更改首选项时,永远不会调用onSharedPreferenceChanged
方法:
SettingsActivity
为什么?