List of usage examples for android.content Context ACCOUNT_SERVICE
String ACCOUNT_SERVICE
To view the source code for android.content Context ACCOUNT_SERVICE.
Click Source Link
From source file:org.kontalk.ui.ConversationList.java
/** Big upgrade: asymmetric key encryption (for XMPP). */ private boolean xmppUpgrade() { AccountManager am = (AccountManager) getSystemService(Context.ACCOUNT_SERVICE); Account account = Authenticator.getDefaultAccount(am); if (account != null) { if (!Authenticator.hasPersonalKey(am, account)) { // first of all, disable offline mode Preferences.setOfflineMode(this, false); String name = Authenticator.getDefaultDisplayName(this); if (name == null || name.length() == 0) { // ask for user name askForPersonalName();/* w w w. ja va 2 s . c o m*/ } else { // proceed to upgrade immediately proceedXmppUpgrade(name); } return true; } } return false; }
From source file:tech.salroid.filmy.syncs.FilmySyncAdapter.java
/** * Helper method to get the fake account to be used with SyncAdapter, or make a new one * if the fake account doesn't exist yet. If we make a new account, we call the * onAccountCreated method so we can initialize things. * * @param context The context used to access the account service * @return a fake account.//from w w w .j ava 2s . co m */ public static Account getSyncAccount(Context context) { // Get an instance of the Android account manager AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE); // Create the account type and default account Account newAccount = new Account(context.getString(R.string.app_name), context.getString(R.string.sync_account_type)); // If the password doesn't exist, the account doesn't exist if (null == accountManager.getPassword(newAccount)) { /* * Add the account and account type, no password or user data * If successful, return the Account object, otherwise report an error. */ if (!accountManager.addAccountExplicitly(newAccount, "", null)) { return null; } /* * If you don't set android:syncable="true" in * in your <provider> element in the manifest, * then call ContentResolver.setIsSyncable(account, AUTHORITY, 1) * here. */ onAccountCreated(newAccount, context); } return newAccount; }
From source file:com.android.managedprovisioning.ProfileOwnerProvisioningActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ProvisionLogger.logd("Profile owner provisioning activity ONCREATE"); mAccountManager = (AccountManager) getSystemService(Context.ACCOUNT_SERVICE); if (savedInstanceState != null) { mCancelStatus = savedInstanceState.getInt(KEY_STATUS, STATUS_PROVISIONING); mPendingProvisioningResult = savedInstanceState.getParcelable(KEY_PENDING_INTENT); }/*from w w w.java 2 s . com*/ initializeLayoutParams(R.layout.progress, R.string.setup_work_profile, true); configureNavigationButtons(NEXT_BUTTON_EMPTY_LABEL, View.INVISIBLE, View.VISIBLE); setTitle(R.string.setup_profile_progress); TextView textView = (TextView) findViewById(R.id.prog_text); if (textView != null) textView.setText(R.string.setting_up_workspace); if (mCancelStatus == STATUS_CANCEL_CONFIRMING) { showCancelProvisioningDialog(); } else if (mCancelStatus == STATUS_CANCELLING) { showCancelProgressDialog(); } mParams = (ProvisioningParams) getIntent().getParcelableExtra(ProvisioningParams.EXTRA_PROVISIONING_PARAMS); if (mParams != null) { maybeSetLogoAndMainColor(mParams.mainColor); } }
From source file:com.ravi.apps.android.newsbytes.sync.NewsSyncAdapter.java
/** * Gets the fictitious account to be used with the sync adapter, or makes a new one * if the fictitious account doesn't exist yet. If we make a new account, we call the * onAccountCreated method so we can initialize things. *///w ww. j a v a2 s. c om public static Account getSyncAccount(Context context) { // Get an instance of the android account manager. AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE); // Create the account type and default account. Account newAccount = new Account(context.getString(R.string.app_name), context.getString(R.string.sync_account_type)); // If the password doesn't exist, the account doesn't exist. Add the account. if (null == accountManager.getPassword(newAccount)) { // Add the account and account type, no password or user data. if (!accountManager.addAccountExplicitly(newAccount, "", null)) { return null; } onAccountCreated(newAccount, context); } return newAccount; }
From source file:com.nick.scalpel.core.AutoFoundWirer.java
private void wireFromContext(Context context, AutoFound.Type type, int idRes, Resources.Theme theme, Field field, Object forWho) { Resources resources = context.getResources(); switch (type) { case STRING://www . j a v a 2s. c o m setField(field, forWho, resources.getString(idRes)); break; case COLOR: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setField(field, forWho, resources.getColor(idRes, theme)); } else { //noinspection deprecation setField(field, forWho, resources.getColor(idRes)); } break; case INTEGER: setField(field, forWho, resources.getInteger(idRes)); break; case BOOL: setField(field, forWho, resources.getBoolean(idRes)); break; case STRING_ARRAY: setField(field, forWho, resources.getStringArray(idRes)); break; case INT_ARRAY: setField(field, forWho, resources.getIntArray(idRes)); break; case PM: setField(field, forWho, context.getSystemService(Context.POWER_SERVICE)); break; case ACCOUNT: setField(field, forWho, context.getSystemService(Context.ACCOUNT_SERVICE)); break; case ALARM: setField(field, forWho, context.getSystemService(Context.ALARM_SERVICE)); break; case AM: setField(field, forWho, context.getSystemService(Context.ACTIVITY_SERVICE)); break; case WM: setField(field, forWho, context.getSystemService(Context.WINDOW_SERVICE)); break; case NM: setField(field, forWho, context.getSystemService(Context.NOTIFICATION_SERVICE)); break; case TM: setField(field, forWho, context.getSystemService(Context.TELEPHONY_SERVICE)); break; case TCM: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setField(field, forWho, context.getSystemService(Context.TELECOM_SERVICE)); } break; case SP: setField(field, forWho, PreferenceManager.getDefaultSharedPreferences(context)); break; case PKM: setField(field, forWho, context.getPackageManager()); break; case HANDLE: setField(field, forWho, new Handler(Looper.getMainLooper())); break; case ASM: setField(field, forWho, context.getSystemService(Context.ACCESSIBILITY_SERVICE)); break; case CAP: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setField(field, forWho, context.getSystemService(Context.CAPTIONING_SERVICE)); } break; case KGD: setField(field, forWho, context.getSystemService(Context.KEYGUARD_SERVICE)); break; case LOCATION: setField(field, forWho, context.getSystemService(Context.LOCATION_SERVICE)); break; case SEARCH: setField(field, forWho, context.getSystemService(Context.SEARCH_SERVICE)); break; case SENSOR: setField(field, forWho, context.getSystemService(Context.SENSOR_SERVICE)); break; case STORAGE: setField(field, forWho, context.getSystemService(Context.STORAGE_SERVICE)); break; case WALLPAPER: setField(field, forWho, context.getSystemService(Context.WALLPAPER_SERVICE)); break; case VIBRATOR: setField(field, forWho, context.getSystemService(Context.VIBRATOR_SERVICE)); break; case CONNECT: setField(field, forWho, context.getSystemService(Context.CONNECTIVITY_SERVICE)); break; case NETWORK_STATUS: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setField(field, forWho, context.getSystemService(Context.NETWORK_STATS_SERVICE)); } break; case WIFI: setField(field, forWho, context.getSystemService(Context.WIFI_SERVICE)); break; case AUDIO: setField(field, forWho, context.getSystemService(Context.AUDIO_SERVICE)); break; case FP: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { setField(field, forWho, context.getSystemService(Context.FINGERPRINT_SERVICE)); } break; case MEDIA_ROUTER: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { setField(field, forWho, context.getSystemService(Context.MEDIA_ROUTER_SERVICE)); } break; case SUB: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { setField(field, forWho, context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE)); } break; case IME: setField(field, forWho, context.getSystemService(Context.INPUT_METHOD_SERVICE)); break; case CLIP_BOARD: setField(field, forWho, context.getSystemService(Context.CLIPBOARD_SERVICE)); break; case APP_WIDGET: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setField(field, forWho, context.getSystemService(Context.APPWIDGET_SERVICE)); } break; case DEVICE_POLICY: setField(field, forWho, context.getSystemService(Context.DEVICE_POLICY_SERVICE)); break; case DOWNLOAD: setField(field, forWho, context.getSystemService(Context.DOWNLOAD_SERVICE)); break; case BATTERY: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setField(field, forWho, context.getSystemService(Context.BATTERY_SERVICE)); } break; case NFC: setField(field, forWho, context.getSystemService(Context.NFC_SERVICE)); break; case DISPLAY: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { setField(field, forWho, context.getSystemService(Context.DISPLAY_SERVICE)); } break; case USER: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { setField(field, forWho, context.getSystemService(Context.USER_SERVICE)); } break; case APP_OPS: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setField(field, forWho, context.getSystemService(Context.APP_OPS_SERVICE)); } break; case BITMAP: setField(field, forWho, BitmapFactory.decodeResource(resources, idRes, null)); break; } }
From source file:com.android.shell.BugreportReceiver.java
/** * Find the best matching {@link Account} based on build properties. *//*from ww w . j a v a2 s .co m*/ private static Account findSendToAccount(Context context) { final AccountManager am = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE); String preferredDomain = SystemProperties.get("sendbug.preferred.domain"); if (!preferredDomain.startsWith("@")) { preferredDomain = "@" + preferredDomain; } final Account[] accounts = am.getAccounts(); Account foundAccount = null; for (Account account : accounts) { if (Patterns.EMAIL_ADDRESS.matcher(account.name).matches()) { if (!preferredDomain.isEmpty()) { // if we have a preferred domain and it matches, return; otherwise keep // looking if (account.name.endsWith(preferredDomain)) { return account; } else { foundAccount = account; } // if we don't have a preferred domain, just return since it looks like // an email address } else { return account; } } } return foundAccount; }
From source file:co.carlosjimenez.android.currencyalerts.app.sync.ForexSyncAdapter.java
/** * Helper method to get the fake account to be used with SyncAdapter, or make a new one * if the fake account doesn't exist yet. If we make a new account, we call the * onAccountCreated method so we can initialize things. * * @param context The context used to access the account service * @return a fake account.//from w ww . j a v a2 s . c o m */ public static Account getSyncAccount(Context context) { // Get an instance of the Android account manager AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE); // Create the account type and default account Account newAccount = new Account(context.getString(R.string.app_name), context.getString(R.string.sync_account_type)); // If the password doesn't exist, the account doesn't exist if (null == accountManager.getPassword(newAccount)) { /* * Add the account and account type, no password or user data * If successful, return the Account object, otherwise report an error. */ if (!accountManager.addAccountExplicitly(newAccount, "", null)) { return null; } /* * If you don't set android:syncable="true" in * in your <provider> element in the manifest, * then call ContentResolver.setIsSyncable(account, AUTHORITY, 1) * here. */ onAccountCreated(newAccount, context); } return newAccount; }
From source file:com.jackie.sunshine.app.sync.SunshineSyncAdapter.java
/** * Helper method to get the fake account to be used with SyncAdapter, or make a new one * if the fake account doesn't exist yet. If we make a new account, we call the * onAccountCreated method so we can initialize things. * * @param context The context used to access the account service * @return a fake account./* w ww. j a v a 2s .c o m*/ */ public static Account getSyncAccount(Context context) { // Get an instance of the Android account manager AccountManager manager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE); // Create the account type and default account Account newAccount = new Account(context.getString(R.string.app_name), context.getString(R.string.sync_account_type)); // If the password doesn't exist, the account doesn't exist if (manager.getPassword(newAccount) == null) { /* * Add the account and account type, no password or user data * If successful, return the Account object, otherwise report an error. */ if (!manager.addAccountExplicitly(newAccount, "", null)) return null; /* * If you don't set android:syncable="true" in * in your <provider> element in the manifest, * then call ContentResolver.setIsSyncable(account, AUTHORITY, 1) * here. */ onAccountCreated(newAccount, context); } return newAccount; }
From source file:com.rowland.hashtrace.sync.TweetHashTracerSyncAdapter.java
/** * Helper method to get the fake account to be used with SyncAdapter, or * make a new one if the fake account doesn't exist yet. If we make a new * account, we call the onAccountCreated method so we can initialize things. * * @param context The context used to access the account service * @return a fake account.//w ww. ja va 2s .c om */ public static Account getSyncAccount(Context context) { // Get an instance of the Android account manager AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE); // Create the account type and default account Account newAccount = new Account(context.getString(R.string.app_name), context.getString(R.string.sync_account_type)); // If the password doesn't exist, the account doesn't exist if (null == accountManager.getPassword(newAccount)) { /* * Add the account and account type, no password or user data If * successful, return the Account object, otherwise report an error. */ if (!accountManager.addAccountExplicitly(newAccount, "", null)) { return null; } /* * If you don't set android:syncable="true" in in your <provider> * element in the manifest, then call * ContentResolver.setIsSyncable(account, AUTHORITY, 1) here. */ onAccountCreated(newAccount, context); } return newAccount; }
From source file:com.katamaditya.apps.weather4u.weathersync.Weather4USyncAdapter.java
/** * Helper method to get the fake account to be used with SyncAdapter, or make a new one * if the fake account doesn't exist yet. If we make a new account, we call the * onAccountCreated method so we can initialize things. * * @param context The context used to access the account service * @return a fake account./*w w w. j a v a2s.c o m*/ */ public static Account getSyncAccount(Context context) { //Log.d("Weather4USyncAdapter", "getSyncAccount"); // Get an instance of the Android account manager AccountManager accountManager = (AccountManager) context.getSystemService(Context.ACCOUNT_SERVICE); // Create the account type and default account Account newAccount = new Account(context.getString(R.string.app_name), context.getString(R.string.sync_account_type)); // If the password doesn't exist, the account doesn't exist if (null == accountManager.getPassword(newAccount)) { /* * Add the account and account type, no password or user data * If successful, return the Account object, otherwise report an error. */ if (!accountManager.addAccountExplicitly(newAccount, "", null)) { return null; } /* * If you don't set android:syncable="true" in * in your <provider> element in the manifest, * then call ContentResolver.setIsSyncable(account, AUTHORITY, 1) * here. */ onAccountCreated(newAccount, context); } return newAccount; }