blob: cdd1afe19a11904b43bd01e7f65ff748f234bf60 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package de.pixart.messenger.services;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.preference.PreferenceManager;
import android.util.Log;
import de.pixart.messenger.Config;
public class EventReceiver extends BroadcastReceiver {
public static final String SETTING_ENABLED_ACCOUNTS = "enabled_accounts";
@Override
public void onReceive(Context context, Intent intent) {
Intent mIntentForService = new Intent(context, XmppConnectionService.class);
if (intent.getAction() != null) {
mIntentForService.setAction(intent.getAction());
} else {
mIntentForService.setAction("other");
}
final String action = intent.getAction();
if (action.equals("ui") || hasEnabledAccounts(context)) {
context.startService(mIntentForService);
} else {
Log.d(Config.LOGTAG, "EventReceiver ignored action " + mIntentForService.getAction());
}
}
public boolean hasEnabledAccounts(Context context) {
return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SETTING_ENABLED_ACCOUNTS, true);
}
}
|