Example usage for android.content IntentFilter addDataScheme

List of usage examples for android.content IntentFilter addDataScheme

Introduction

In this page you can find the example usage for android.content IntentFilter addDataScheme.

Prototype

public final void addDataScheme(String scheme) 

Source Link

Document

Add a new Intent data scheme to match against.

Usage

From source file:com.android.music.ArtistAlbumBrowserFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    View view = inflater.inflate(R.layout.media_picker_activity_expanding, null);
    getActivity().setVolumeControlStream(AudioManager.STREAM_MUSIC);
    mToken = MusicUtils.bindToService(getActivity(), this);

    if (savedInstanceState != null) {
        mCurrentAlbumId = savedInstanceState.getString("selectedalbum");
        mCurrentAlbumName = savedInstanceState.getString("selectedalbumname");
        mCurrentArtistId = savedInstanceState.getString("selectedartist");
        mCurrentArtistName = savedInstanceState.getString("selectedartistname");
    }/*from w  w w  . j  a va 2s .c  o  m*/

    IntentFilter f = new IntentFilter();
    f.addAction(Intent.ACTION_MEDIA_SCANNER_STARTED);
    f.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED);
    f.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
    f.addDataScheme("file");
    getActivity().registerReceiver(mScanListener, f);

    lv = (ExpandableListView) view.findViewById(android.R.id.list);

    mAdapter = (ArtistAlbumListAdapter) getActivity().getLastNonConfigurationInstance();
    if (mAdapter == null) {
        //Log.i("@@@", "starting query");
        mAdapter = new ArtistAlbumListAdapter(getActivity().getApplication(), this, null, // cursor
                R.layout.track_list_item_group, new String[] {}, new int[] {}, R.layout.track_list_item_child,
                new String[] {}, new int[] {});
        lv.setAdapter(mAdapter);
        getArtistCursor(mAdapter.getQueryHandler(), null);
    } else {
        mAdapter.setActivity(this);
        lv.setAdapter(mAdapter);
        mArtistCursor = mAdapter.getCursor();
        if (mArtistCursor != null) {
            init(mArtistCursor);
        } else {
            getArtistCursor(mAdapter.getQueryHandler(), null);
        }
    }

    lv.setOnCreateContextMenuListener(this);
    lv.setOnChildClickListener(this);
    lv.setTextFilterEnabled(true);

    return view;
}

From source file:com.google.android.apps.iosched2.ui.SessionDetailFragment.java

@Override
public void onResume() {
    super.onResume();
    SetupHelper.loadCurrentSetup(getActivity());

    updateNotesTab();//  www .  ja  va  2  s  .  c  om

    // Start listening for time updates to adjust "now" bar. TIME_TICK is
    // triggered once per minute, which is how we move the bar over time.
    final IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_PACKAGE_ADDED);
    filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
    filter.addDataScheme("package");
    getActivity().registerReceiver(mPackageChangesReceiver, filter);
}

From source file:com.cleanwiz.applock.service.LockService.java

public void registerApplicationReceiver() {
    IntentFilter packageIntentFilter = new IntentFilter();
    IntentFilter eventIntentFilter = new IntentFilter();
    eventIntentFilter.addAction(Intent.ACTION_SCREEN_OFF);
    eventIntentFilter.addAction(Intent.ACTION_SCREEN_ON);
    eventIntentFilter.addAction(Intent.ACTION_TIME_TICK);
    eventIntentFilter.addAction(Intent.ACTION_USER_PRESENT);
    eventIntentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
    packageIntentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    packageIntentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    packageIntentFilter.addDataScheme("package");
    getApplicationContext().registerReceiver(packageReceiver, packageIntentFilter);
    getApplicationContext().registerReceiver(eventReceiver, eventIntentFilter);
    IntentFilter filter = new IntentFilter();
    filter.addAction(LOCK_SERVICE_LASTTIME);
    filter.addAction(LOCK_SERVICE_LEAVEAMENT);
    filter.addAction(LOCK_SERVICE_LEAVERTIME);
    filter.addAction(LOCK_SERVICE_LOCKSTATE);

    lastUnlockTimeSeconds = 0;/*from w w  w . jav a 2  s  .c  om*/
    allowedLeaveAment = application.getAllowedLeaveAment();
    leaverTime = application.getLeaverTime();
    lockState = application.getAppLockState();
    registerReceiver(new ServiceReceiver(), filter);
}

From source file:com.google.android.apps.muzei.settings.SettingsChooseSourceFragment.java

@Override
public void onResume() {
    super.onResume();
    updateSources();/*from w  ww  .j  a  v  a2s .c o m*/

    IntentFilter packageChangeIntentFilter = new IntentFilter();
    packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
    packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    packageChangeIntentFilter.addDataScheme("package");
    getActivity().registerReceiver(mPackagesChangedReceiver, packageChangeIntentFilter);
}

From source file:com.android.tv.settings.users.AppRestrictionsFragment.java

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

    getActivity().registerReceiver(mUserBackgrounding, new IntentFilter(Intent.ACTION_USER_BACKGROUND));
    IntentFilter packageFilter = new IntentFilter();
    packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    packageFilter.addDataScheme("package");
    getActivity().registerReceiver(mPackageObserver, packageFilter);

    mAppListChanged = false;/* ww w  . j a  v  a2s  .c  o m*/
    if (mAppLoadingTask == null || mAppLoadingTask.getStatus() == AsyncTask.Status.FINISHED) {
        mAppLoadingTask = new AppLoadingTask().execute();
    }
}

From source file:com.compal.telephonytest.TelephonyTest.java

public void prepareSMS() {

    IntentFilter sendIntentFilter = new IntentFilter(SMS_SEND_ACTION);
    IntentFilter deliveryIntentFilter = new IntentFilter(SMS_DELIVERY_ACTION);
    IntentFilter dataSmsReceivedIntentFilter = new IntentFilter(DATA_SMS_RECEIVED_ACTION);

    mSendIntent = new Intent(SMS_SEND_ACTION);
    mDeliveryIntent = new Intent(SMS_DELIVERY_ACTION);

    dataSmsReceivedIntentFilter.addDataScheme("sms");
    dataSmsReceivedIntentFilter.addDataAuthority("localhost", port.toString());

    context.registerReceiver(SmsBroadcastReceiver, sendIntentFilter);
    context.registerReceiver(SmsBroadcastReceiver, deliveryIntentFilter);
    context.registerReceiver(SmsBroadcastReceiver, dataSmsReceivedIntentFilter);

    mText = mText + "_" + Long.toString(System.currentTimeMillis());

    PendingIntent mSentIntent = PendingIntent.getBroadcast(getInstrumentation().getTargetContext(), 0,
            mSendIntent, PendingIntent.FLAG_ONE_SHOT);
    PendingIntent mDeliveredIntent = PendingIntent.getBroadcast(getInstrumentation().getTargetContext(), 0,
            mDeliveryIntent, PendingIntent.FLAG_ONE_SHOT);

    byte[] data = mText.getBytes();
    mSmsManager.sendDataMessage(mPhoneNumber, null, port, data, mSentIntent, mDeliveredIntent);

}

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

/**
 * Internal constructor that only performs initial parsing.
 *//*from ww w.j a  va  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.google.android.apps.muzei.settings.ChooseSourceFragment.java

@Override
public void onResume() {
    super.onResume();
    updateSources();/* w w w  . j a va  2s .  c  om*/

    IntentFilter packageChangeIntentFilter = new IntentFilter();
    packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
    packageChangeIntentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    packageChangeIntentFilter.addDataScheme("package");
    getContext().registerReceiver(mPackagesChangedReceiver, packageChangeIntentFilter);
}

From source file:edu.cmu.mpcs.dashboard.TagViewer.java

private void enableTagWriteMode() {
    Log.d("TAG_VIEWER", "in enable tag write");
    mWriteMode = true;//  w w  w. j a v  a 2  s .com
    IntentFilter tagDetected = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
    // tagDetected.addDataScheme("http");
    // IntentFilter techFilter = new
    // IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED);
    try {
        tagDetected.addDataType("text/plain");
        // tagDetected.addDataScheme("http");
        // techFilter.addDataType("text/plain");
    } catch (MalformedMimeTypeException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    IntentFilter httpDetected = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
    httpDetected.addDataScheme("http");

    mWriteTagFilters = new IntentFilter[] { tagDetected, httpDetected };
    mNfcAdapter.enableForegroundDispatch(this, mNfcPendingIntent, mWriteTagFilters, null);
}

From source file:org.linkdroid.BroadcastReceiverService.java

private void enableIntentFilterAtCursor(Cursor c) throws MalformedMimeTypeException {
    final IntentFilter intentFilter = new IntentFilter();
    final String intentStr = c.getString(c.getColumnIndexOrThrow(ACTION));
    intentFilter.addAction(intentStr);/*ww  w .j av a2 s.  c om*/
    final String categoryStr = c.getString(c.getColumnIndexOrThrow(CATEGORY));
    if (StringUtils.isBlank(categoryStr)) {
        intentFilter.addCategory(Intent.CATEGORY_DEFAULT);
    } else {
        intentFilter.addCategory(categoryStr);
    }
    final String dataAuthHostStr = c.getString(c.getColumnIndexOrThrow(DATA_AUTHORITY_HOST));
    final String dataAuthPortStr = c.getString(c.getColumnIndexOrThrow(DATA_AUTHORITY_PORT));
    if (!StringUtils.isBlank(dataAuthHostStr)) {
        intentFilter.addDataAuthority(dataAuthHostStr, dataAuthPortStr);
    }
    final String dataSchemeStr = c.getString(c.getColumnIndexOrThrow(DATA_SCHEME));
    if (!StringUtils.isBlank(dataSchemeStr)) {
        intentFilter.addDataScheme(dataSchemeStr);
    }
    final String dataTypeStr = c.getString(c.getColumnIndexOrThrow(DATA_TYPE));
    if (!StringUtils.isBlank(dataTypeStr)) {
        intentFilter.addDataType(dataTypeStr);
    }
    registerReceiver(receiver, intentFilter);
    Log.d(TAG, "registered intent filter " + intentStr);
}