Example usage for android.content Intent ACTION_EXTERNAL_APPLICATIONS_AVAILABLE

List of usage examples for android.content Intent ACTION_EXTERNAL_APPLICATIONS_AVAILABLE

Introduction

In this page you can find the example usage for android.content Intent ACTION_EXTERNAL_APPLICATIONS_AVAILABLE.

Prototype

String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE

To view the source code for android.content Intent ACTION_EXTERNAL_APPLICATIONS_AVAILABLE.

Click Source Link

Document

Broadcast Action: Resources for a set of packages (which were previously unavailable) are currently available since the media on which they exist is available.

Usage

From source file:com.mobileglobe.android.customdialer.common.model.AccountTypeManager.java

/**
 * Internal constructor that only performs initial parsing.
 *///  w w w .jav a  2s .  c o  m
public AccountTypeManagerImpl(Context context) {
    mContext = context;
    mFallbackAccountType = new FallbackAccountType(context);

    mAccountManager = AccountManager.get(mContext);

    mListenerThread = new HandlerThread("AccountChangeListener");
    mListenerThread.start();
    mListenerHandler = new Handler(mListenerThread.getLooper()) {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
            case MESSAGE_LOAD_DATA:
                loadAccountsInBackground();
                break;
            case MESSAGE_PROCESS_BROADCAST_INTENT:
                processBroadcastIntent((Intent) msg.obj);
                break;
            }
        }
    };

    mInvitableAccountTypeCache = new InvitableAccountTypeCache();

    // Request updates when packages or accounts change
    IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
    filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    filter.addDataScheme("package");
    mContext.registerReceiver(mBroadcastReceiver, filter);
    IntentFilter sdFilter = new IntentFilter();
    sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
    sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
    mContext.registerReceiver(mBroadcastReceiver, sdFilter);

    // Request updates when locale is changed so that the order of each field will
    // be able to be changed on the locale change.
    filter = new IntentFilter(Intent.ACTION_LOCALE_CHANGED);
    mContext.registerReceiver(mBroadcastReceiver, filter);

    if (ActivityCompat.checkSelfPermission(mContext,
            Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED) {
        // TODO: Consider calling
        //    ActivityCompat#requestPermissions
        // here to request the missing permissions, and then overriding
        //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
        //                                          int[] grantResults)
        // to handle the case where the user grants the permission. See the documentation
        // for ActivityCompat#requestPermissions for more details.
        return;
    }
    mAccountManager.addOnAccountsUpdatedListener(this, mListenerHandler, false);

    ContentResolver.addStatusChangeListener(ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS, this);

    mListenerHandler.sendEmptyMessage(MESSAGE_LOAD_DATA);
}

From source file:com.android.contacts.model.AccountTypeManager.java

/**
 * Internal constructor that only performs initial parsing.
 *//*www  . ja va  2  s  .  com*/
public AccountTypeManagerImpl(Context context) {
    mContext = context;
    mLocalAccountLocator = DeviceLocalAccountLocator.create(context);
    mTypeProvider = new AccountTypeProvider(context);
    mFallbackAccountType = new FallbackAccountType(context);

    mAccountManager = AccountManager.get(mContext);

    mExecutor = ContactsExecutors.getDefaultThreadPoolExecutor();
    mMainThreadExecutor = ContactsExecutors.newHandlerExecutor(mMainThreadHandler);

    // Request updates when packages or accounts change
    IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
    filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    filter.addDataScheme("package");
    mContext.registerReceiver(mBroadcastReceiver, filter);
    IntentFilter sdFilter = new IntentFilter();
    sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
    sdFilter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
    mContext.registerReceiver(mBroadcastReceiver, sdFilter);

    // Request updates when locale is changed so that the order of each field will
    // be able to be changed on the locale change.
    filter = new IntentFilter(Intent.ACTION_LOCALE_CHANGED);
    mContext.registerReceiver(mBroadcastReceiver, filter);

    mAccountManager.addOnAccountsUpdatedListener(this, mMainThreadHandler, false);

    ContentResolver.addStatusChangeListener(ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS, this);

    if (Flags.getInstance().getBoolean(Experiments.CP2_DEVICE_ACCOUNT_DETECTION_ENABLED)) {
        // Observe changes to RAW_CONTACTS so that we will update the list of "Device" accounts
        // if a new device contact is added.
        mContext.getContentResolver().registerContentObserver(ContactsContract.RawContacts.CONTENT_URI,
                /* notifyDescendents */ true, new ContentObserver(mMainThreadHandler) {
                    @Override
                    public boolean deliverSelfNotifications() {
                        return true;
                    }

                    @Override
                    public void onChange(boolean selfChange) {
                        reloadLocalAccounts();
                    }

                    @Override
                    public void onChange(boolean selfChange, Uri uri) {
                        reloadLocalAccounts();
                    }
                });
    }
    loadAccountTypes();
}

From source file:com.cognizant.trumobi.PersonaLauncher.java

private void registerIntentReceivers() {
    boolean useNotifReceiver = PersonaAlmostNexusSettingsHelper.getNotifReceiver(this);
    if (useNotifReceiver && mCounterReceiver == null) {
        mCounterReceiver = new PersonaCounterReceiver(this);
        mCounterReceiver.setCounterListener(new PersonaCounterReceiver.OnCounterChangedListener() {
            public void onTrigger(String pname, int counter, int color) {
                PersonaLog.d("personalauncher", "updateCountersForPackage called from registerIntentReceivers");
                //updateCountersForPackage(pname, counter, color, 0);
                Bundle b = new Bundle();

                b.putString("package", "com.cognizant.trumobi");
                b.putInt("counter", counter);
                b.putInt("color", R.color.PR_TEXTBOX_FOCUSED_COLOR);
                b.putInt("updateCountFor", 0);
                Message m = new Message();
                m.setData(b);/*from  w  ww.  j  a v a 2s.c o  m*/
                UiHandler.sendMessage(m);
            }
        });
        registerReceiver(mCounterReceiver, mCounterReceiver.getFilter());
    }

    IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
    filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    filter.addDataScheme("package");
    registerReceiver(mApplicationsReceiver, filter);
    filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    registerReceiver(mCloseSystemDialogsReceiver, filter);
    filter = new IntentFilter();
    filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
    filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
    registerReceiver(mApplicationsReceiver, filter);

}