Example usage for android.content Intent setClass

List of usage examples for android.content Intent setClass

Introduction

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

Prototype

public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) 

Source Link

Document

Convenience for calling #setComponent(ComponentName) with the name returned by a Class object.

Usage

From source file:terse.a1.TerseActivity.java

void startTerseActivity(String actPath, String actQuery, String... extrasKV) {

    Uri uri = new Uri.Builder().scheme("terse").path(actPath).encodedQuery(actQuery).build();
    Intent intent = new Intent("android.intent.action.MAIN", uri);
    intent.setClass(getApplicationContext(), TerseActivity.class);
    for (int i = 0; i < extrasKV.length; i += 2) {
        intent.putExtra(extrasKV[i], extrasKV[i + 1]);
    }/* w ww  .  ja  v  a  2s  . c om*/
    startActivity(intent);
}

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

@Override
public boolean onContextItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case PLAY_SELECTION: {
        // play the track
        int position = mSelectedPosition;
        MusicUtils.playAll(getActivity(), mTrackCursor, position);
        return true;
    }/* w  ww.  j a  v a 2 s .  com*/

    case QUEUE: {
        long[] list = new long[] { mSelectedId };
        MusicUtils.addToCurrentPlaylist(getActivity(), list);
        return true;
    }

    case NEW_PLAYLIST: {
        Intent intent = new Intent();
        intent.setClass(getActivity(), CreatePlaylist.class);
        startActivityForResult(intent, NEW_PLAYLIST);
        return true;
    }

    case PLAYLIST_SELECTED: {
        long[] list = new long[] { mSelectedId };
        long playlist = item.getIntent().getLongExtra("playlist", 0);
        MusicUtils.addToPlaylist(getActivity(), list, playlist);
        return true;
    }

    case USE_AS_RINGTONE:
        // Set the system setting to make this the current ringtone
        MusicUtils.setRingtone(getActivity(), mSelectedId);
        return true;

    case DELETE_ITEM: {
        long[] list = new long[1];
        list[0] = (int) mSelectedId;
        Bundle b = new Bundle();
        String f;
        if (android.os.Environment.isExternalStorageRemovable()) {
            f = getString(R.string.delete_song_desc);
        } else {
            f = getString(R.string.delete_song_desc_nosdcard);
        }
        String desc = String.format(f, mCurrentTrackName);
        b.putString("description", desc);
        b.putLongArray("items", list);
        Intent intent = new Intent();
        intent.setClass(getActivity(), DeleteItems.class);
        intent.putExtras(b);
        startActivityForResult(intent, -1);
        return true;
    }

    case REMOVE:
        removePlaylistItem(mSelectedPosition);
        return true;

    case SEARCH:
        doSearch();
        return true;
    }
    return super.onContextItemSelected(item);
}

From source file:com.ifeel.healthy.SelectionFragment.java

private void startPracticePartnerActivity(Uri data, int requestCode) {
    Intent intent = new Intent();
    intent.setData(data);/*from  w w w.  j  av  a2s.co  m*/
    intent.setClass(getActivity(), ContactsListActivity.class);
    startActivityForResult(intent, requestCode);
}

From source file:com.ifeel.healthy.SelectionFragment.java

private void startHistoryGraphActivity(Uri data, int requestCode) {
    Intent intent = new Intent();
    intent.setData(data);// w  ww  .  j  av a 2  s.  c  om
    intent.setClass(getActivity(), HistoryGraphActivity3.class);
    startActivityForResult(intent, requestCode);
}

From source file:com.ifeel.healthy.SelectionFragment.java

private void startMindfulBreadingActivity(Uri data, int requestCode) {
    Intent intent = new Intent();
    intent.setData(data);/*from w  w  w . ja v a 2s .  c  om*/
    intent.setClass(getActivity(), com.agustinprats.myhrv.MainActivity.class);
    startActivityForResult(intent, requestCode);
}

From source file:com.lewa.crazychapter11.MainActivity.java

private void AddPeopleProvideBtn() {
    Button btn_people_provider = (Button) findViewById(R.id.btn_people_provider);
    btn_people_provider.setOnClickListener(new OnClickListener() {
        @Override/* w  ww . j  a  v a 2 s .c  o m*/
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setClass(MainActivity.this, ProviderMainActivity.class);
            startActivity(intent);
        }
    });
}

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

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    badSymptoms.saveMenu("menu", item.toString());

    Intent intent;
    try {//ww  w.  ja  v  a  2 s  .com
        switch (item.getItemId()) {
        case GOTO_START:
            intent = new Intent();
            intent.setClass(this, MusicBrowserActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            finish();
            break;
        case USE_AS_RINGTONE: {
            // Set the system setting to make this the current ringtone
            if (mService != null) {
                MusicUtils.setRingtone(this, mService.getAudioId());
            }
            return true;
        }
        case PARTY_SHUFFLE:
            MusicUtils.togglePartyShuffle();
            setShuffleButtonImage();
            break;

        case NEW_PLAYLIST: {
            intent = new Intent();
            intent.setClass(this, CreatePlaylist.class);
            startActivityForResult(intent, NEW_PLAYLIST);
            return true;
        }

        case PLAYLIST_SELECTED: {
            long[] list = new long[1];
            list[0] = MusicUtils.getCurrentAudioId();
            long playlist = item.getIntent().getLongExtra("playlist", 0);
            MusicUtils.addToPlaylist(this, list, playlist);
            return true;
        }

        case DELETE_ITEM: {
            if (mService != null) {
                long[] list = new long[1];
                list[0] = MusicUtils.getCurrentAudioId();
                Bundle b = new Bundle();
                String f;
                if (android.os.Environment.isExternalStorageRemovable()) {
                    f = getString(R.string.delete_song_desc, mService.getTrackName());
                } else {
                    f = getString(R.string.delete_song_desc_nosdcard, mService.getTrackName());
                }
                b.putString("description", f);
                b.putLongArray("items", list);
                intent = new Intent();
                intent.setClass(this, DeleteItems.class);
                intent.putExtras(b);
                startActivityForResult(intent, -1);
            }
            return true;
        }

        case EFFECTS_PANEL: {
            Intent i = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);
            i.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, mService.getAudioSessionId());
            startActivityForResult(i, EFFECTS_PANEL);
            return true;
        }
        }
    } catch (RemoteException ex) {
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.ifeel.healthy.SelectionFragment.java

private void startSessionActivity(Uri data, int requestCode) {
    Intent intent = new Intent();
    intent.setData(data);/*from  ww w  .  j a v  a  2s.  c  o  m*/
    intent.putExtra("PracticeSession", true);
    intent.setClass(getActivity(), com.agustinprats.myhrv.MainActivity.class);
    startActivityForResult(intent, requestCode);
}

From source file:com.lewa.crazychapter11.MainActivity.java

private void AddUsageStatsBtn() {
    Button btn_usagestats = (Button) findViewById(R.id.btn_usagestats);
    btn_usagestats.setOnClickListener(new OnClickListener() {
        @Override// w ww. j a v a  2  s.c  om
        public void onClick(View v) {
            Intent intent = new Intent();
            // */
            intent.setClass(MainActivity.this, UsageStatsActivity.class);
            // */
            startActivity(intent);
        }
    });
}

From source file:com.lewa.crazychapter11.MainActivity.java

private void AddTestBtn() {
    Button btn_test = (Button) findViewById(R.id.btn_test);
    btn_test.setOnClickListener(new OnClickListener() {
        @Override//from w  w  w  . j  a  va 2  s . co m
        public void onClick(View v) {
            Intent intent = new Intent();
            // */
            intent.setClass(MainActivity.this, TestMainActivity.class);
            // */
            startActivity(intent);

            refreshDesk();
        }
    });
}