-1
我在我的應用中使用parse.com推送通知。我說像這樣的「禁用通知」選項,應用程序設置:禁用解析通知
<PreferenceCategory android:title="Obvestila" >
<CheckBoxPreference
android:defaultValue="true"
android:key="prefNotification"
android:summary="Za obvestila je potrebna internetna povezava"
android:title="Prejemal obvestila" />
</PreferenceCategory>
,然後添加這個方法來MainActivity:
public void getSettingsPrefs(){
SharedPreferences settingsPrefs = PreferenceManager.getDefaultSharedPreferences(this);
notification = settingsPrefs.getBoolean("prefNotification", true);
if (notification == false)
{
PushService.setDefaultPushCallback(this, null);
}
else
{
PushService.setDefaultPushCallback(this, MainActivity.class);
}
}
現在的問題是,這只是部分有效。一旦我選中或取消選中設置中的框,我需要完全重新打開MainActivity,以便在onCreate中執行getSettingsPrefs()。如何在每次複選框被選中時執行IF語句?