List of usage examples for android.accounts AccountManager get
public static AccountManager get(Context context)
From source file:de.dhbw.organizer.calendar.backend.syncadapter.SyncAdapter.java
public SyncAdapter(Context context, boolean autoInitialize) { super(context, autoInitialize); mContext = context;/* w w w . ja v a2 s .c o m*/ mAccountManager = AccountManager.get(context); mCalendarManager = CalendarManager.get(mContext); }
From source file:eu.ttbox.androgister.sync.syncadapter.OrderSyncAdapter.java
public OrderSyncAdapter(Context context, boolean autoInitialize) { super(context, autoInitialize); mContext = context; mAccountManager = AccountManager.get(context); }
From source file:com.flowzr.budget.holo.export.flowzr.FlowzrSyncTask.java
public static android.accounts.Account getAndroidAccount(Context context) { String accountName = MyPreferences.getFlowzrAccount(context); AccountManager accountManager = AccountManager.get(context); android.accounts.Account[] accounts = accountManager.getAccountsByType("com.google"); Account useCredential = null;//from w w w .ja va 2 s . c o m for (int i = 0; i < accounts.length; i++) { if (accountName.equals(((android.accounts.Account) accounts[i]).name)) { return accounts[i]; } } return null; }
From source file:com.nicolacimmino.expensestracker.tracker.data_sync.ExpenseDataSyncAdapter.java
public ExpenseDataSyncAdapter(Context context, boolean autoInitialize) { super(context, autoInitialize); mAccountManager = AccountManager.get(context); }
From source file:com.clearcenter.mobile_demo.mdSyncAdapter.java
public mdSyncAdapter(Context context, boolean autoInitialize) { super(context, autoInitialize); ctx = context;//from w w w. j a v a 2 s . c o m account_manager = AccountManager.get(context); last_sample = new HashMap<String, Long>(); Log.d(TAG, "SyncAdapter created..."); }
From source file:eu.masconsult.bgbanking.accounts.AccountAuthenticator.java
public AccountAuthenticator(Context context) { super(context); this.context = context; accountManager = AccountManager.get(context); }
From source file:org.klnusbaum.udj.ArtistsLoader.java
private ArtistsResult attemptLoad(boolean attemptReauth) { AccountManager am = AccountManager.get(getContext()); String authToken = ""; try {//w w w. j a v a2s . c o m authToken = am.blockingGetAuthToken(account, "", true); } catch (IOException e) { //TODO this might actually be an auth error return new ArtistsResult(null, ArtistsError.AUTHENTICATION_ERROR); } catch (AuthenticatorException e) { return new ArtistsResult(null, ArtistsError.AUTHENTICATION_ERROR); } catch (OperationCanceledException e) { return new ArtistsResult(null, ArtistsError.AUTHENTICATION_ERROR); } try { String playerId = am.getUserData(account, Constants.LAST_PLAYER_ID_DATA); return getArtists(playerId, authToken); } catch (JSONException e) { return new ArtistsResult(null, ArtistsError.SERVER_ERROR); } catch (ParseException e) { return new ArtistsResult(null, ArtistsError.SERVER_ERROR); } catch (IOException e) { return new ArtistsResult(null, ArtistsError.SERVER_ERROR); } catch (AuthenticationException e) { if (attemptReauth) { Log.d(TAG, "soft auth failure"); am.invalidateAuthToken(Constants.ACCOUNT_TYPE, authToken); return attemptLoad(false); } else { Log.d(TAG, "hard auth failure"); return new ArtistsResult(null, ArtistsError.AUTHENTICATION_ERROR); } } catch (PlayerInactiveException e) { return new ArtistsResult(null, ArtistsError.PLAYER_INACTIVE_ERROR); } catch (NoLongerInPlayerException e) { return new ArtistsResult(null, ArtistsError.NO_LONGER_IN_PLAYER_ERROR); } catch (KickedException e) { return new ArtistsResult(null, ArtistsError.KICKED_ERROR); } }
From source file:com.Duo.music.player.Dialogs.GooglePlayMusicAuthenticationDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { parentActivity = getActivity();/*from w w w.java 2 s .co m*/ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); sharedPreferences = parentActivity.getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE); View rootView = parentActivity.getLayoutInflater().inflate(R.layout.dialog_google_authentication_layout, null); //Check if this dialog was called from the Welcome sequence. mFirstRun = getArguments().getBoolean(Common.FIRST_RUN); infoText = (TextView) rootView.findViewById(R.id.google_authentication_dialog_text); infoText.setTypeface(TypefaceHelper.getTypeface(getActivity(), "RobotoCondensed-Light")); infoText.setPaintFlags(infoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); final AccountManager accountManager = AccountManager.get(getActivity().getApplicationContext()); final Account[] accounts = accountManager.getAccountsByType("com.google"); final int size = accounts.length; String[] accountNames = new String[size]; for (int i = 0; i < size; i++) { accountNames[i] = accounts[i].name; } //Set the dialog title. builder.setTitle(R.string.sign_in_google_play_music); builder.setCancelable(false); builder.setItems(accountNames, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { account = accounts[which]; sharedPreferences.edit().putString("GOOGLE_PLAY_MUSIC_ACCOUNT", account.name).commit(); AsyncGoogleMusicAuthenticationTask task = new AsyncGoogleMusicAuthenticationTask( parentActivity.getApplicationContext(), parentActivity, mFirstRun, account.name); task.execute(); } }); return builder.create(); }
From source file:com.taxicop.sync.SyncAdapter.java
public SyncAdapter(Context context, boolean autoInitialize) { super(context, autoInitialize); mContext = context;//from ww w.j a va 2 s .c om dba = new DataBase(context); mAccountManager = AccountManager.get(context); insert = new ArrayList<ContentValues>(); FROM = 0; }
From source file:com.jelly.music.player.Dialogs.GooglePlayMusicAuthenticationDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { parentActivity = getActivity();//from w ww. j a va 2s.co m AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); sharedPreferences = parentActivity.getSharedPreferences("com.jelly.music.player", Context.MODE_PRIVATE); View rootView = parentActivity.getLayoutInflater().inflate(R.layout.dialog_google_authentication_layout, null); //Check if this dialog was called from the Welcome sequence. mFirstRun = getArguments().getBoolean(Common.FIRST_RUN); infoText = (TextView) rootView.findViewById(R.id.google_authentication_dialog_text); infoText.setTypeface(TypefaceHelper.getTypeface(getActivity(), "RobotoCondensed-Light")); infoText.setPaintFlags(infoText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); final AccountManager accountManager = AccountManager.get(getActivity().getApplicationContext()); final Account[] accounts = accountManager.getAccountsByType("com.google"); final int size = accounts.length; String[] accountNames = new String[size]; for (int i = 0; i < size; i++) { accountNames[i] = accounts[i].name; } //Set the dialog title. builder.setTitle(R.string.sign_in_google_play_music); builder.setCancelable(false); builder.setItems(accountNames, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { account = accounts[which]; sharedPreferences.edit().putString("GOOGLE_PLAY_MUSIC_ACCOUNT", account.name).commit(); AsyncGoogleMusicAuthenticationTask task = new AsyncGoogleMusicAuthenticationTask( parentActivity.getApplicationContext(), parentActivity, mFirstRun, account.name); task.execute(); } }); return builder.create(); }