Example usage for android.accounts AccountManager addOnAccountsUpdatedListener

List of usage examples for android.accounts AccountManager addOnAccountsUpdatedListener

Introduction

In this page you can find the example usage for android.accounts AccountManager addOnAccountsUpdatedListener.

Prototype

public void addOnAccountsUpdatedListener(final OnAccountsUpdateListener listener, Handler handler,
        boolean updateImmediately) 

Source Link

Document

Adds an OnAccountsUpdateListener to this instance of the AccountManager .

Usage

From source file:Main.java

@SuppressLint({ "MissingPermission" })
public static void addOnAccountsUpdatedListener(Context context, final OnAccountsUpdateListener listener,
        Handler handler, boolean updateImmediately) {
    AccountManager accountManager = AccountManager.get(context);
    accountManager.addOnAccountsUpdatedListener(listener, handler, updateImmediately);
}

From source file:com.cerema.cloud2.files.services.FileDownloader.java

/**
 * Service initialization/*  w  ww . j  av a  2 s .c o m*/
 */
@Override
public void onCreate() {
    super.onCreate();
    Log_OC.d(TAG, "Creating service");
    mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    HandlerThread thread = new HandlerThread("FileDownloaderThread", Process.THREAD_PRIORITY_BACKGROUND);
    thread.start();
    mServiceLooper = thread.getLooper();
    mServiceHandler = new ServiceHandler(mServiceLooper, this);
    mBinder = new FileDownloaderBinder();

    // add AccountsUpdatedListener
    AccountManager am = AccountManager.get(getApplicationContext());
    am.addOnAccountsUpdatedListener(this, null, false);
}

From source file:com.cerema.cloud2.files.services.FileUploader.java

/**
 * Service initialization/*from   w w w . j a v  a  2s .  com*/
 */
@Override
public void onCreate() {
    super.onCreate();
    Log_OC.d(TAG, "Creating service");
    mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    HandlerThread thread = new HandlerThread("FileUploaderThread", Process.THREAD_PRIORITY_BACKGROUND);
    thread.start();
    mServiceLooper = thread.getLooper();
    mServiceHandler = new ServiceHandler(mServiceLooper, this);
    mBinder = new FileUploaderBinder();

    // add AccountsUpdatedListener
    AccountManager am = AccountManager.get(getApplicationContext());
    am.addOnAccountsUpdatedListener(this, null, false);
}