Exemplo n.º 1
0
  @Override
  public void onCreate(ServiceProxy context) {
    this.context = context;
    checkPlayServices();

    this.notificationManager =
        (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    notificationBuilder = new NotificationCompat.Builder(context);

    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);

    this.preferencesChangedListener =
        new SharedPreferences.OnSharedPreferenceChangeListener() {
          @Override
          public void onSharedPreferenceChanged(SharedPreferences sharedPreference, String key) {
            if (key.equals(Preferences.getKey(R.string.keyNotificationEnabled)))
              handleNotification();
            else if (key.equals(Preferences.getKey(R.string.keyNotificationGeocoderEnabled)))
              handleNotification();
            else if (key.equals(Preferences.getKey(R.string.keyNotificationLocationEnabled)))
              handleNotification();
            else if (key.equals(Preferences.getKey(R.string.keyContactsLinkCloudStorageEnabled)))
              updateAllContacts();
          }
        };

    this.handler = new StaticHandler(this);

    sharedPreferences.registerOnSharedPreferenceChangeListener(this.preferencesChangedListener);
    handleNotification();

    this.mContactCount = getContactCount();
    context
        .getContentResolver()
        .registerContentObserver(ContactsContract.Contacts.CONTENT_URI, true, this.mObserver);
  }