use of android.accounts.Account in project android-volley by mcxiaoke.
the class AndroidAuthenticatorTest method setUp.
@Before
public void setUp() {
mAccountManager = mock(AccountManager.class);
mFuture = mock(AccountManagerFuture.class);
mAccount = new Account("coolperson", "cooltype");
mAuthenticator = new AndroidAuthenticator(mAccountManager, mAccount, "cooltype", false);
}
use of android.accounts.Account in project Signal-Android by WhisperSystems.
the class DirectoryHelper method createAccount.
private static Optional<AccountHolder> createAccount(Context context) {
AccountManager accountManager = AccountManager.get(context);
Account account = new Account(context.getString(R.string.app_name), "org.thoughtcrime.securesms");
if (accountManager.addAccountExplicitly(account, null, null)) {
Log.w(TAG, "Created new account...");
ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1);
return Optional.of(new AccountHolder(account, true));
} else {
Log.w(TAG, "Failed to create account!");
return Optional.absent();
}
}
use of android.accounts.Account in project FastDev4Android by jiangqqlmj.
the class AndroidAuthenticatorTest method setUp.
@Before
public void setUp() {
mAccountManager = mock(AccountManager.class);
mFuture = mock(AccountManagerFuture.class);
mAccount = new Account("coolperson", "cooltype");
mAuthenticator = new AndroidAuthenticator(mAccountManager, mAccount, "cooltype", false);
}
use of android.accounts.Account in project PushSms by koush.
the class MyActivity method onCreate.
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
accounts = getSharedPreferences("accounts", MODE_PRIVATE);
settings = getSharedPreferences("settings", MODE_PRIVATE);
ListView lv = (ListView) findViewById(R.id.list);
View header = getLayoutInflater().inflate(R.layout.header, null);
lv.addHeaderView(header);
lv.setAdapter(accountAdapter = new AccountAdapter());
final Switch toggle = (Switch) header.findViewById(R.id.toggle);
toggle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
settings.edit().putBoolean("enabled", toggle.isChecked()).commit();
}
});
toggle.setChecked(settings.getBoolean("enabled", true));
final Button phoneNumber = (Button) header.findViewById(R.id.phone_number);
phoneNumber.setText(getNumber());
phoneNumber.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final EditText input = new EditText(MyActivity.this);
new AlertDialog.Builder(MyActivity.this).setTitle(R.string.phone_number).setView(input).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
settings.edit().putString("phone_number", input.getText().toString()).commit();
phoneNumber.setText(getNumber());
}
}).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Do nothing.
}
}).show();
}
});
for (Account account : AccountManager.get(this).getAccountsByType("com.google")) {
accountAdapter.add(account);
}
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
CheckedTextView tv = (CheckedTextView) view.findViewById(android.R.id.text1);
Account account = accountAdapter.getItem((int) id);
if (tv.isChecked()) {
accounts.edit().putBoolean(account.name, false).commit();
tv.toggle();
reregister();
return;
}
login(account.name);
}
});
startService(new Intent(this, MiddlewareService.class));
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new Thread() {
@Override
public void run() {
try {
GoogleCloudMessaging.getInstance(MyActivity.this).unregister();
} catch (Exception e) {
}
}
}.start();
}
});
}
use of android.accounts.Account in project SeriesGuide by UweTrottmann.
the class TraktCredentials method getAccessToken.
/**
* Get the access token. Avoid keeping this in memory, maybe calling {@link #hasCredentials()}
* is sufficient.
*/
public String getAccessToken() {
Account account = AccountUtils.getAccount(mContext);
if (account == null) {
return null;
}
AccountManager manager = AccountManager.get(mContext);
return manager.getPassword(account);
}
Aggregations