本文整理汇总了Java中android.accounts.OnAccountsUpdateListener类的典型用法代码示例。如果您正苦于以下问题:Java OnAccountsUpdateListener类的具体用法?Java OnAccountsUpdateListener怎么用?Java OnAccountsUpdateListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OnAccountsUpdateListener类属于android.accounts包,在下文中一共展示了OnAccountsUpdateListener类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FinskyDrawerLayout
import android.accounts.OnAccountsUpdateListener; //导入依赖的package包/类
public FinskyDrawerLayout(final Context paramContext, AttributeSet paramAttributeSet)
{
super(paramContext, paramAttributeSet);
this.mAccountManager = AccountManager.get(paramContext);
this.mOnAccountsUpdateListener = new OnAccountsUpdateListener()
{
public final void onAccountsUpdated(Account[] paramAnonymousArrayOfAccount)
{
Utils.syncDebugActivityStatus(paramContext);
FinskyDrawerLayout.this.refresh();
}
};
this.mCurrentBackendId = 0;
this.mRefreshRunnable = new Runnable()
{
public final void run()
{
FinskyDrawerLayout.this.refresh();
}
};
this.mRefreshHandler = new Handler(Looper.myLooper());
}
示例2: addOnAccountsUpdatedListener
import android.accounts.OnAccountsUpdateListener; //导入依赖的package包/类
/**
* This method should be called only from Singletons so the lifecycle
* is tied with the application, so we don't have to cleanup the listeners
*
* @param callback to be called on accounts updated
*/
public void addOnAccountsUpdatedListener(OnAccountsUpdatedListener callback) {
try {
OnAccountsUpdateListener listener = accounts -> {
Set<MovirtAccount> filtered = new HashSet<>();
for (Account account : accounts) {
if (Constants.ACCOUNT_TYPE.equals(account.type)) {
try {
filtered.add(asMoAccount(account));
} catch (IllegalStateException incompatibleAccount) {
removeAccount(new MovirtAccount("", account), null); // remove old account
}
}
}
callback.onAccountsUpdated(filtered);
};
accountManager.addOnAccountsUpdatedListener(listener, null, true);
} catch (SecurityException e) {
commonMessageHelper.showError(ErrorType.NORMAL, resources.getMissingAccountsPermissionError());
}
}
示例3: addOnAccountsUpdatedListener
import android.accounts.OnAccountsUpdateListener; //导入依赖的package包/类
@Implementation
public void addOnAccountsUpdatedListener(final OnAccountsUpdateListener listener,
Handler handler, boolean updateImmediately) {
if (listeners.contains(listener)) {
return;
}
listeners.add(listener);
if (updateImmediately) {
listener.onAccountsUpdated(getAccounts());
}
}
示例4: notifyListeners
import android.accounts.OnAccountsUpdateListener; //导入依赖的package包/类
private void notifyListeners() {
Account[] accounts = getAccounts();
Iterator<OnAccountsUpdateListener> iter = listeners.iterator();
OnAccountsUpdateListener listener;
while (iter.hasNext()) {
listener = iter.next();
listener.onAccountsUpdated(accounts);
}
}
示例5: XOnAccountsUpdateListener
import android.accounts.OnAccountsUpdateListener; //导入依赖的package包/类
public XOnAccountsUpdateListener(OnAccountsUpdateListener listener, int uid) {
mListener = listener;
mUid = uid;
}
示例6: onCreate
import android.accounts.OnAccountsUpdateListener; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
mHandler = new Handler();
// init preferences
Preferences.init(this);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
mPrefChangedListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
// no account - abort
if (Authenticator.getDefaultAccount(Kontalk.this) == null)
return;
// manual server address
if ("pref_network_uri".equals(key)) {
// just restart the message center for now
android.util.Log.w(TAG, "network address changed");
MessageCenterService.restart(Kontalk.this);
}
// hide presence flag / encrypt user data flag
else if ("pref_hide_presence".equals(key) || "pref_encrypt_userdata".equals(key)) {
MessageCenterService.updateStatus(Kontalk.this);
}
// changing remove prefix
else if ("pref_remove_prefix".equals(key)) {
SyncAdapter.requestSync(getApplicationContext(), true);
}
}
};
prefs.registerOnSharedPreferenceChangeListener(mPrefChangedListener);
// TODO listen for changes to phone numbers
Account account = Authenticator.getDefaultAccount(this);
if (account != null) {
// update notifications from locally unread messages
MessagingNotification.updateMessagesNotification(this, false);
// register account change listener
final OnAccountsUpdateListener listener = new OnAccountsUpdateListener() {
@Override
public void onAccountsUpdated(Account[] accounts) {
Account my = null;
for (int i = 0; i < accounts.length; i++) {
if (accounts[i].type.equals(Authenticator.ACCOUNT_TYPE)) {
my = accounts[i];
break;
}
}
// account removed!!! Shutdown everything.
if (my == null) {
Log.w(TAG, "my account has been removed, shutting down");
// delete all messages
MessagesProvider.deleteDatabase(Kontalk.this);
// stop message center
MessageCenterService.stop(Kontalk.this);
// invalidate cached personal key
invalidatePersonalKey();
}
}
};
AccountManager am = AccountManager.get(this);
// register listener to handle account removal
am.addOnAccountsUpdatedListener(listener, mHandler, true);
}
// enable/disable components
setServicesEnabled(this, account != null);
}
示例7: onCreate
import android.accounts.OnAccountsUpdateListener; //导入依赖的package包/类
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Accounts spinner
this.accountSpinner = (Spinner) findViewById(R.id.accountSpinner);
Listactivity.currentList = new ArrayList<String>();
// Spinner item selection Listener
this.accountSpinner.setOnItemSelectedListener(this);
imapNotes2Account = new ImapNotes2Account();
Listactivity.accountManager = AccountManager.get(getApplicationContext());
Listactivity.accountManager.addOnAccountsUpdatedListener((OnAccountsUpdateListener)
new AccountsUpdateListener(), null, true);
status = (TextView)findViewById(R.id.status);
this.spinnerList = new ArrayAdapter<String>
(this, android.R.layout.simple_spinner_item,Listactivity.currentList);
spinnerList.setDropDownViewResource
(android.R.layout.simple_spinner_dropdown_item);
this.accountSpinner.setAdapter(spinnerList);
this.noteList = new ArrayList<OneNote>();
((ImapNotes2)this.getApplicationContext()).SetNotesList(this.noteList);
this.listToView = new NotesListAdapter(
getApplicationContext(),
this.noteList,
R.layout.note_element,
new String[]{"title","date"},
new int[]{R.id.noteTitle, R.id.noteInformation});
listview = (ListView) findViewById(R.id.notesList);
listview.setAdapter(this.listToView);
listview.setTextFilterEnabled(true);
this.imapFolder = new Imaper();
((ImapNotes2)this.getApplicationContext()).SetImaper(this.imapFolder);
if (Listactivity.storedNotes == null)
storedNotes = new NotesDb(getApplicationContext());
// When item is clicked, we go to NoteDetailActivity
listview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View widget, int selectedNote, long arg3) {
Intent toDetail = new Intent(widget.getContext(), NoteDetailActivity.class);
toDetail.putExtra("selectedNote", (OneNote)arg0.getItemAtPosition(selectedNote));
toDetail.putExtra("useSticky", Listactivity.imapNotes2Account.GetUsesticky());
startActivityForResult(toDetail,SEE_DETAIL);
}
});
editAccountButton = (Button) findViewById(R.id.editAccountButton);
editAccountButton.setOnClickListener(clickListenerEditAccount);
}