Example usage for android.accounts AccountManager LOGIN_ACCOUNTS_CHANGED_ACTION

List of usage examples for android.accounts AccountManager LOGIN_ACCOUNTS_CHANGED_ACTION

Introduction

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

Prototype

String LOGIN_ACCOUNTS_CHANGED_ACTION

To view the source code for android.accounts AccountManager LOGIN_ACCOUNTS_CHANGED_ACTION.

Click Source Link

Document

Action sent as a broadcast Intent by the AccountsService when accounts are added, accounts are removed, or an account's credentials (saved password, etc) are changed.

Usage

From source file:org.mozilla.gecko.fxa.AccountLoader.java

protected void registerObserver(BroadcastReceiver observer) {
    final IntentFilter intentFilter = new IntentFilter();
    // Android Account added or removed.
    intentFilter.addAction(AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION);
    // Firefox Account internal state changed.
    intentFilter.addAction(FxAccountConstants.ACCOUNT_STATE_CHANGED_ACTION);

    // null means: "the main thread of the process will be used." We must call
    // onContentChanged on the main thread of the process; this ensures we do.
    final Handler handler = null;
    getContext().registerReceiver(observer, intentFilter, FxAccountConstants.PER_ACCOUNT_TYPE_PERMISSION,
            handler);//from www.j  a  va2 s.com
}

From source file:com.example.suspectedBug.myapplication.IapSampleActivity.java

@Override
protected void onResume() {
    super.onResume();

    // Register to receive notifications about account changes. This will re-query
    // the receipt list in order to ensure it is always up to date for whomever
    // is logged in.
    IntentFilter accountsChangedFilter = new IntentFilter(AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION);
    registerReceiver(mAuthChangeReceiver, accountsChangedFilter);
}

From source file:com.goodhustle.ouyaunitybridge.OuyaUnityActivity.java

@Override
protected void onStart() {
    super.onStart();
    // Immediately request an up-to-date copy of receipts.
    requestReceipts();//from w w w  .  j  a  v a2  s .c  o m

    // Register to receive notifications about account changes. This will re-query the receipt
    // list in order to ensure it is always up to date for whomever is logged in.
    accountsChangedFilter = new IntentFilter();
    accountsChangedFilter.addAction(AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION);
    registerReceiver(mAuthChangeReceiver, accountsChangedFilter);

    // listen for controller changes - http://developer.android.com/reference/android/hardware/input/InputManager.html#registerInputDeviceListener%28android.hardware.input.InputManager.InputDeviceListener,%20android.os.Handler%29
    Context context = getBaseContext();
    mInputManager = (InputManager) context.getSystemService(Context.INPUT_SERVICE);
    mInputManager.registerInputDeviceListener(this, null);
    sendDevices();
}

From source file:tv.ouya.sample.IapSampleActivity.java

/**
 * Request an up to date list of receipts and start listening for any account changes
 * whilst the application is running.// ww  w  .  j  a v a2 s  .  co m
 */
@Override
public void onStart() {
    super.onStart();

    // Request an up to date list of receipts for the user.
    requestReceipts();

    // Register to receive notifications about account changes. This will re-query
    // the receipt list in order to ensure it is always up to date for whomever
    // is logged in.
    IntentFilter accountsChangedFilter = new IntentFilter();
    accountsChangedFilter.addAction(AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION);
    registerReceiver(mAuthChangeReceiver, accountsChangedFilter);
}

From source file:org.tigase.mobile.accountstatus.AccountsStatusFragment.java

@Override
public void onStart() {
    super.onStart();
    final MultiJaxmpp jaxmpp = ((MessengerApplication) getActivity().getApplicationContext()).getMultiJaxmpp();

    jaxmpp.addListener(Connector.StateChanged, this.connectorListener);
    jaxmpp.addListener(JaxmppCore.Connected, this.connectedListener);

    getActivity().getApplicationContext().registerReceiver(this.accountModifiedReceiver,
            new IntentFilter(AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION));

    loadData();/* ww w  .j a  v a 2 s.  c om*/
}

From source file:org.tigase.messenger.phone.pro.service.XMPPService.java

@Override
public void onCreate() {
    super.onCreate();
    Log.i("XMPPService", "Service started");

    getApplication().registerActivityLifecycleCallbacks(mActivityCallbacks);

    this.ownPresenceStanzaFactory = new OwnPresenceFactoryImpl();
    this.dbHelper = DatabaseHelper.getInstance(this);
    this.connManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    this.dataRemover = new DataRemover(this.dbHelper);

    SSLSessionCache sslSessionCache = new SSLSessionCache(this);
    this.sslSocketFactory = SSLCertificateSocketFactory.getDefault(0, sslSessionCache);

    this.rosterProvider = new RosterProviderExt(this, dbHelper, new RosterProviderExt.Listener() {
        @Override//w w  w . ja v a 2  s .  co m
        public void onChange(Long rosterItemId) {
            Uri uri = rosterItemId != null ? ContentUris.withAppendedId(RosterProvider.ROSTER_URI, rosterItemId)
                    : RosterProvider.ROSTER_URI;

            Log.i(TAG, "Content change: " + uri);
            getApplicationContext().getContentResolver().notifyChange(uri, null);

        }
    }, "roster_version");
    rosterProvider.resetStatus();

    this.mobileModeFeature = new MobileModeFeature(this);

    this.presenceHandler = new PresenceHandler(this);
    this.messageHandler = new MessageHandler(this);
    this.chatProvider = new org.tigase.messenger.jaxmpp.android.chat.ChatProvider(this, dbHelper,
            new org.tigase.messenger.jaxmpp.android.chat.ChatProvider.Listener() {
                @Override
                public void onChange(Long chatId) {
                    Uri uri = chatId != null ? ContentUris.withAppendedId(ChatProvider.OPEN_CHATS_URI, chatId)
                            : ChatProvider.OPEN_CHATS_URI;
                    getApplicationContext().getContentResolver().notifyChange(uri, null);
                }
            });
    chatProvider.resetRoomState(CPresence.OFFLINE);
    this.mucHandler = new MucHandler();
    this.capsCache = new CapabilitiesDBCache(dbHelper);

    IntentFilter screenStateReceiverFilter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    screenStateReceiverFilter.addAction(Intent.ACTION_SCREEN_OFF);
    registerReceiver(screenStateReceiver, screenStateReceiverFilter);

    registerReceiver(presenceChangedReceiver, new IntentFilter(CLIENT_PRESENCE_CHANGED_ACTION));

    registerReceiver(connReceiver, new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"));

    multiJaxmpp.addHandler(
            StreamManagementModule.StreamManagementFailedHandler.StreamManagementFailedEvent.class,
            new StreamManagementModule.StreamManagementFailedHandler() {
                @Override
                public void onStreamManagementFailed(final SessionObject sessionObject,
                        XMPPException.ErrorCondition condition) {
                    if (condition != null && condition.getElementName().equals("item-not-found")) {
                        XMPPService.this.rosterProvider.resetStatus(sessionObject);
                    }
                }
            });
    multiJaxmpp.addHandler(DiscoveryModule.ServerFeaturesReceivedHandler.ServerFeaturesReceivedEvent.class,
            streamHandler);
    multiJaxmpp.addHandler(JaxmppCore.LoggedInHandler.LoggedInEvent.class, jaxmppConnectedHandler);
    multiJaxmpp.addHandler(JaxmppCore.LoggedOutHandler.LoggedOutEvent.class, jaxmppDisconnectedHandler);
    // multiJaxmpp.addHandler(SocketConnector.ErrorHandler.ErrorEvent.class,
    // );
    //
    // this.connectorListener = new Connector.ErrorHandler() {
    //
    // @Override
    // public void onError(SessionObject sessionObject, StreamError
    // condition, Throwable caught) throws JaxmppException {
    // AbstractSocketXmppSessionLogic.this.processConnectorErrors(condition,
    // caught);
    // }
    // };
    multiJaxmpp.addHandler(PresenceModule.ContactAvailableHandler.ContactAvailableEvent.class, presenceHandler);
    multiJaxmpp.addHandler(PresenceModule.ContactUnavailableHandler.ContactUnavailableEvent.class,
            presenceHandler);
    multiJaxmpp.addHandler(PresenceModule.ContactChangedPresenceHandler.ContactChangedPresenceEvent.class,
            presenceHandler);
    multiJaxmpp.addHandler(PresenceModule.SubscribeRequestHandler.SubscribeRequestEvent.class,
            subscribeHandler);

    multiJaxmpp.addHandler(MessageModule.MessageReceivedHandler.MessageReceivedEvent.class, messageHandler);
    multiJaxmpp.addHandler(MessageCarbonsModule.CarbonReceivedHandler.CarbonReceivedEvent.class,
            messageHandler);
    multiJaxmpp.addHandler(ChatStateExtension.ChatStateChangedHandler.ChatStateChangedEvent.class,
            messageHandler);
    multiJaxmpp.addHandler(AuthModule.AuthFailedHandler.AuthFailedEvent.class,
            new AuthModule.AuthFailedHandler() {

                @Override
                public void onAuthFailed(SessionObject sessionObject, SaslModule.SaslError error)
                        throws JaxmppException {
                    processAuthenticationError((Jaxmpp) multiJaxmpp.get(sessionObject));
                }
            });

    multiJaxmpp.addHandler(MucModule.MucMessageReceivedHandler.MucMessageReceivedEvent.class, mucHandler);
    multiJaxmpp.addHandler(MucModule.MessageErrorHandler.MessageErrorEvent.class, mucHandler);
    multiJaxmpp.addHandler(MucModule.YouJoinedHandler.YouJoinedEvent.class, mucHandler);
    multiJaxmpp.addHandler(MucModule.StateChangeHandler.StateChangeEvent.class, mucHandler);
    multiJaxmpp.addHandler(MucModule.PresenceErrorHandler.PresenceErrorEvent.class, mucHandler);

    IntentFilter filterAccountModifyReceiver = new IntentFilter();
    filterAccountModifyReceiver.addAction(LoginActivity.ACCOUNT_MODIFIED_MSG);
    filterAccountModifyReceiver.addAction(AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION);
    registerReceiver(accountModifyReceiver, filterAccountModifyReceiver);

    startKeepAlive();

    updateJaxmppInstances();
    // connectAllJaxmpp();
}