Code example for IntentFilter

Methods: addAction, addDataScheme, registerReceiver

0
    public void onResume() { 
        super.onResume(); 
        updateList(); 
 
        // listen for package changes 
        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_PACKAGE_ADDED);
        filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
        filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
        filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
        filter.addDataScheme("package");
        getActivity().registerReceiver(mPackageReceiver, filter);
 
        mCR.registerContentObserver(ENABLED_NOTIFICATION_LISTENERS_URI, false, mSettingsObserver);
    } 
 
    @Override 
    public void onPause() { 
        super.onPause(); 
 
        getActivity().unregisterReceiver(mPackageReceiver);