Android Open Source - Weather-app Sunshine Authenticator






From Project

Back to project page Weather-app.

License

The source code is released under:

Apache License

If you think the Android project Weather-app listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package app.sunshine.juanjo.sync;
/* w  w w  . ja  va 2  s  .  c o m*/
/**
 * Created by juanjo on 29/08/14.
 */

import android.accounts.AbstractAccountAuthenticator;
import android.accounts.Account;
import android.accounts.AccountAuthenticatorResponse;
import android.accounts.NetworkErrorException;
import android.content.Context;
import android.os.Bundle;

/**
 * Manages "Authentication" to Sunshine's backend service. The SyncAdapter
 * framework requires an authenticator object, so syncing to a service that
 * doesn't need authentication typically means creating a stub authenticator
 * like this one. This code is copied directly, in its entirety, from
 * http://developer
 * .android.com/training/sync-adapters/creating-authenticator.html Which is a
 * pretty handy reference when creating your own syncadapters. Just sayin'.
 */
public class SunshineAuthenticator extends AbstractAccountAuthenticator {

  public SunshineAuthenticator(Context context) {
    super(context);
  }

  // No properties to edit.
  @Override
  public Bundle editProperties(AccountAuthenticatorResponse r, String s) {
    throw new UnsupportedOperationException();
  }

  // Because we're not actually adding an account to the device, just return
  // null.
  @Override
  public Bundle addAccount(AccountAuthenticatorResponse r, String s, String s2, String[] strings,
      Bundle bundle) throws NetworkErrorException {
    return null;
  }

  // Ignore attempts to confirm credentials
  @Override
  public Bundle confirmCredentials(AccountAuthenticatorResponse r, Account account, Bundle bundle)
      throws NetworkErrorException {
    return null;
  }

  // Getting an authentication token is not supported
  @Override
  public Bundle getAuthToken(AccountAuthenticatorResponse r, Account account, String s,
      Bundle bundle) throws NetworkErrorException {
    throw new UnsupportedOperationException();
  }

  // Getting a label for the auth token is not supported
  @Override
  public String getAuthTokenLabel(String s) {
    throw new UnsupportedOperationException();
  }

  // Updating user credentials is not supported
  @Override
  public Bundle updateCredentials(AccountAuthenticatorResponse r, Account account, String s,
      Bundle bundle) throws NetworkErrorException {
    throw new UnsupportedOperationException();
  }

  // Checking features for the account is not supported
  @Override
  public Bundle hasFeatures(AccountAuthenticatorResponse r, Account account, String[] strings)
      throws NetworkErrorException {
    throw new UnsupportedOperationException();
  }
}




Java Source Code List

app.sunshine.juanjo.gcm.GcmBroadcastReceiver.java
app.sunshine.juanjo.gcm.GcmIntentService.java
app.sunshine.juanjo.network.APIHTTP.java
app.sunshine.juanjo.network.HttpRequest.java
app.sunshine.juanjo.network.SendIdGCM.java
app.sunshine.juanjo.sync.SunshineAuthenticatorService.java
app.sunshine.juanjo.sync.SunshineAuthenticator.java
app.sunshine.juanjo.sync.SunshineSyncAdapter.java
app.sunshine.juanjo.sync.SunshineSyncService.java
app.sunshine.juanjo.util.Utility.java
app.sunshine.juanjo.util.WeatherContract.java
app.sunshine.juanjo.util.WeatherDbHelper.java
app.sunshine.juanjo.util.WeatherJsonParser.java
app.sunshine.juanjo.util.WeatherProvider.java
app.sunshine.juanjo.views.MyView.java
app.sunshine.juanjo.views.activities.DetailActivity.java
app.sunshine.juanjo.views.activities.MainActivity.java
app.sunshine.juanjo.views.activities.SettingsActivity.java
app.sunshine.juanjo.views.adapter.ForecastAdapter.java
app.sunshine.juanjo.views.fragments.DetailFragment.java
app.sunshine.juanjo.views.fragments.ForeCastFragment.java