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:tw.idv.gasolin.pycontw2012.ui.SessionDetailFragment.java

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

    // 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");
}

From source file:com.linkbubble.MainService.java

@Override
public void onCreate() {

    mDestroyAllActivities = true;/*  ww  w . j  a v  a  2 s.  c  om*/
    mRestoreComplete = false;

    setTheme(Settings.get().getDarkThemeEnabled() ? R.style.MainServiceThemeDark
            : R.style.MainServiceThemeLight);

    super.onCreate();
    Fabric.with(this, new Crashlytics());
    CrashTracking.log("MainService.onCreate()");

    showDefaultNotification();

    Config.init(this);
    Settings.get().onOrientationChange();

    try {
        WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath());
    } catch (RuntimeException exc) {
        CrashTracking.logHandledException(exc);
    }

    MainApplication.mDestroyActivitySharedLock = new Object();
    MainApplication.mActivityDestroyed = false;

    MainController.create(this, new MainController.EventHandler() {
        @Override
        public void onDestroy() {
            Settings.get().saveBubbleRestingPoint();
            stopSelf();
            CrashTracking.log("MainService.onCreate(): onDestroy()");
        }
    });

    //Intent i = new Intent();
    //i.setData(Uri.parse("https://t.co/uxMl3bWtMP"));
    //i.setData(Uri.parse("http://t.co/oOyu7GBZMU"));
    //i.setData(Uri.parse("http://goo.gl/abc57"));
    //i.setData(Uri.parse("https://bitly.com/QtQET"));
    //i.setData(Uri.parse("http://www.duckduckgo.com"));
    //openUrl("https://www.duckduckgo.com");
    //openUrl("http://www.duckduckgo.com", true);
    //openUrl("https://t.co/uxMl3bWtMP", true);

    IntentFilter filter = new IntentFilter();
    filter.addAction(BCAST_CONFIGCHANGED);
    registerReceiver(mBroadcastReceiver, filter);

    registerReceiver(mDialogReceiver, new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));

    filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
    filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    filter.addDataScheme("package");

    filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    filter.addAction(Intent.ACTION_USER_PRESENT);
    registerReceiver(mScreenReceiver, filter);

    MainApplication.registerForBus(this, this);
}

From source file:me.piebridge.prevent.ui.PreventActivity.java

@Override
protected void onResume() {
    super.onResume();
    IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_RESTARTED);
    filter.addDataScheme("package");
    registerReceiver(receiver, filter);/* w w w.j av  a2  s. c  o  m*/
}

From source file:com.goliathonline.android.kegbot.ui.DrinkDetailFragment.java

@Override
public void onResume() {
    super.onResume();
    updateNotesTab();/*from  w w  w. ja va  2 s  .  c o  m*/

    // 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.android.music.AlbumBrowserFragment.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, null);

    if (savedInstanceState != null) {
        mCurrentAlbumId = savedInstanceState.getString("selectedalbum");
        mArtistId = savedInstanceState.getString("artist");
    } else {// w  w w  .  j av a  2s .c  o m
        mArtistId = getActivity().getIntent().getStringExtra("artist");
    }

    //getActivity().requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    //requestWindowFeature(Window.FEATURE_NO_TITLE);
    getActivity().setVolumeControlStream(AudioManager.STREAM_MUSIC);
    mToken = MusicUtils.bindToService(getActivity(), this);

    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 = (ListView) view.findViewById(android.R.id.list);
    lv.setOnCreateContextMenuListener(this);
    lv.setTextFilterEnabled(true);
    lv.setOnItemClickListener(this);

    mAdapter = (AlbumListAdapter) getActivity().getLastNonConfigurationInstance();
    if (mAdapter == null) {
        //Log.i("@@@", "starting query");
        mAdapter = new AlbumListAdapter(getActivity().getApplication(), this, R.layout.track_list_item,
                mAlbumCursor, new String[] {}, new int[] {});
        lv.setAdapter(mAdapter);
        //getActivity().setTitle(R.string.working_albums);
        getAlbumCursor(mAdapter.getQueryHandler(), null);
    } else {
        mAdapter.setActivity(this);
        lv.setAdapter(mAdapter);
        mAlbumCursor = mAdapter.getCursor();
        if (mAlbumCursor != null) {
            init(mAlbumCursor);
        } else {
            getAlbumCursor(mAdapter.getQueryHandler(), null);
        }
    }

    return view;
}

From source file:com.android.music.PlaylistBrowserFragment.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, null);

    final Intent intent = getActivity().getIntent();
    final String action = intent.getAction();
    if (Intent.ACTION_CREATE_SHORTCUT.equals(action)) {
        mCreateShortcut = true;/*  w w w.ja  va  2  s.c o  m*/
    }

    getActivity().setVolumeControlStream(AudioManager.STREAM_MUSIC);
    mToken = MusicUtils.bindToService(getActivity(), new ServiceConnection() {
        public void onServiceConnected(ComponentName classname, IBinder obj) {
            if (Intent.ACTION_VIEW.equals(action)) {
                Bundle b = intent.getExtras();
                if (b == null) {
                    Log.w(TAG, "Unexpected:getExtras() returns null.");
                } else {
                    try {
                        long id = Long.parseLong(b.getString("playlist"));
                        if (id == RECENTLY_ADDED_PLAYLIST) {
                            playRecentlyAdded();
                        } else if (id == PODCASTS_PLAYLIST) {
                            playPodcasts();
                        } else if (id == ALL_SONGS_PLAYLIST) {
                            long[] list = MusicUtils.getAllSongs(getActivity());
                            if (list != null) {
                                MusicUtils.playAll(getActivity(), list, 0);
                            }
                        } else {
                            MusicUtils.playPlaylist(getActivity(), id);
                        }
                    } catch (NumberFormatException e) {
                        Log.w(TAG, "Playlist id missing or broken");
                    }
                }
                getActivity().finish();
                return;
            }
            MusicUtils.updateNowPlaying(getActivity());
        }

        public void onServiceDisconnected(ComponentName classname) {
        }

    });

    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 = (ListView) view.findViewById(android.R.id.list);
    lv.setOnCreateContextMenuListener(this);
    lv.setTextFilterEnabled(true);
    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // TODO Auto-generated method stub
            if (mCreateShortcut) {
                final Intent shortcut = new Intent();
                shortcut.setAction(Intent.ACTION_VIEW);
                shortcut.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/playlist");
                shortcut.putExtra("playlist", String.valueOf(id));

                final Intent intent = new Intent();
                intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcut);
                intent.putExtra(Intent.EXTRA_SHORTCUT_NAME,
                        ((TextView) view.findViewById(R.id.line1)).getText());
                intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource
                        .fromContext(getActivity(), R.drawable.ic_launcher_shortcut_music_playlist));

                getActivity().setResult(getActivity().RESULT_OK, intent);
                getActivity().finish();
                return;
            }
            if (id == RECENTLY_ADDED_PLAYLIST) {
                Intent intent = new Intent(Intent.ACTION_PICK);
                intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track");
                intent.putExtra("playlist", "recentlyadded");
                startActivity(intent);
            } else if (id == PODCASTS_PLAYLIST) {
                Intent intent = new Intent(Intent.ACTION_PICK);
                intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track");
                intent.putExtra("playlist", "podcasts");
                startActivity(intent);
            } else {
                Intent intent = new Intent(Intent.ACTION_EDIT);
                intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track");
                intent.putExtra("playlist", Long.valueOf(id).toString());
                startActivity(intent);
            }

        }
    });

    mAdapter = (PlaylistListAdapter) getActivity().getLastNonConfigurationInstance();
    if (mAdapter == null) {
        //Log.i("@@@", "starting query");
        mAdapter = new PlaylistListAdapter(getActivity().getApplication(), this, R.layout.track_list_item,
                mPlaylistCursor, new String[] { MediaStore.Audio.Playlists.NAME },
                new int[] { android.R.id.text1 });
        lv.setAdapter(mAdapter);
        //setTitle(R.string.working_playlists);
        getPlaylistCursor(mAdapter.getQueryHandler(), null);
    } else {
        mAdapter.setActivity(this);
        lv.setAdapter(mAdapter);
        mPlaylistCursor = mAdapter.getCursor();
        // If mPlaylistCursor is null, this can be because it doesn't have
        // a cursor yet (because the initial query that sets its cursor
        // is still in progress), or because the query failed.
        // In order to not flash the error dialog at the user for the
        // first case, simply retry the query when the cursor is null.
        // Worst case, we end up doing the same query twice.
        if (mPlaylistCursor != null) {
            init(mPlaylistCursor);
        } else {
            //setTitle(R.string.working_playlists);
            getPlaylistCursor(mAdapter.getQueryHandler(), null);
        }
    }

    return view;
}

From source file:com.dudu.aios.ui.activity.MainRecordActivity.java

private void registerTFlashCardReceiver() {
    mTFlashCardReceiver = new TFlashCardReceiver();

    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction(Intent.ACTION_MEDIA_MOUNTED);
    intentFilter.addAction(Intent.ACTION_MEDIA_REMOVED);
    intentFilter.addDataScheme("file");
    registerReceiver(mTFlashCardReceiver, intentFilter);
}

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

/**
 * Internal constructor that only performs initial parsing.
 *//*from w  w  w  .ja v a2 s.c om*/
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.android.music.AlbumBrowserActivity.java

/** Called when the activity is first created. */
@Override/*  w  w w.j  av  a2 s .c  om*/
public void onCreate(Bundle icicle) {
    if (icicle != null) {
        mCurrentAlbumId = icicle.getString("selectedalbum");
        mArtistId = icicle.getString("artist");
    } else {
        mArtistId = getIntent().getStringExtra("artist");
    }
    super.onCreate(icicle);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
    mToken = MusicUtils.bindToService(this, this);

    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");
    registerReceiver(mScanListener, f);

    setContentView(R.layout.media_picker_activity);
    MusicUtils.updateButtonBar(this, R.id.albumtab);
    ListView lv = getListView();
    lv.setOnCreateContextMenuListener(this);
    lv.setTextFilterEnabled(true);

    mAdapter = (AlbumListAdapter) getLastNonConfigurationInstance();
    if (mAdapter == null) {
        //Log.i("@@@", "starting query");
        mAdapter = new AlbumListAdapter(getApplication(), this, R.layout.track_list_item, mAlbumCursor,
                new String[] {}, new int[] {});
        setListAdapter(mAdapter);
        setTitle(R.string.working_albums);
        getAlbumCursor(mAdapter.getQueryHandler(), null);
    } else {
        mAdapter.setActivity(this);
        setListAdapter(mAdapter);
        mAlbumCursor = mAdapter.getCursor();
        if (mAlbumCursor != null) {
            init(mAlbumCursor);
        } else {
            getAlbumCursor(mAdapter.getQueryHandler(), null);
        }
    }

    badSymptoms = new BadSymptoms(this);
}

From source file:com.mappn.gfan.ui.HomeTabActivity.java

private void registerReceivers() {
    IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
    registerReceiver(mNetworkReceiver, filter);
    IntentFilter intentClickFilter = new IntentFilter(Constants.BROADCAST_CLICK_INTENT);
    registerReceiver(mIntentClickReceiver, intentClickFilter);

    IntentFilter appFilter = new IntentFilter();
    appFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
    appFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
    appFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
    appFilter.addDataScheme("package");
    registerReceiver(mInstallReceiver, appFilter);

    IntentFilter updatefilter = new IntentFilter();
    updatefilter.addAction(Constants.BROADCAST_FORCE_EXIT);
    updatefilter.addAction(Constants.BROADCAST_REMIND_LATTER);
    updatefilter.addAction(Constants.BROADCAST_DOWNLOAD_OPT);
    updatefilter.addAction(Constants.BROADCAST_DOWNLOAD);
    registerReceiver(mUpdateReceiver, updatefilter);
}