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:com.sft.blackcatapp.EnrollSchoolActivity.java

@Override
protected void onActivityResult(int requestCode, final int resultCode, final Intent data) {
    if (data != null) {
        if (resultCode == R.id.base_left_btn) {
            SchoolVO school = (SchoolVO) data.getSerializableExtra("school");
            if (app.userVO != null && app.userVO.getApplystate().equals(EnrollResult.SUBJECT_NONE.getValue())
                    && school != null) {
                int position = adapter.getData().indexOf(school);
                adapter.setSelected(position);
                adapter.notifyDataSetChanged();
            }/*from   ww w  .  ja v a  2s  .  com*/
            return;
        }
        if (isFromMenu) {
            data.setClass(this, ApplyActivity.class);
            data.putExtra("isFromMenu", isFromMenu);
            startActivity(data);
        }
        new MyHandler(200) {
            @Override
            public void run() {
                setResult(resultCode, data);
                finish();
            }
        };
    }
}

From source file:com.android.contacts.activities.ContactDetailActivity.java

/** @} */

@Override//from  w  w  w . j  a va  2 s .  c  om
protected void onCreate(Bundle savedState) {
    super.onCreate(savedState);
    LogUtils.i(TAG, "[onCreate][launch]start");
    ///M: Bug Fix for ALPS01022809,JE happens when click the favourite video to choose contact in tablet
    registerPHBReceiver();
    mIsActivitFinished = false;
    /** M: Bug Fix for ALPS00393950 @{ */
    boolean isUsingTwoPanes = PhoneCapabilityTester.isUsingTwoPanes(this);
    if (!isUsingTwoPanes) {
        SetIndicatorUtils.getInstance().registerReceiver(this);
    }
    /** @} */
    if (PhoneCapabilityTester.isUsingTwoPanes(this)) {
        // This activity must not be shown. We have to select the contact in the
        // PeopleActivity instead ==> Create a forward intent and finish
        final Intent originalIntent = getIntent();
        Intent intent = new Intent();
        intent.setAction(originalIntent.getAction());
        intent.setDataAndType(originalIntent.getData(), originalIntent.getType());

        // If we are launched from the outside, we should create a new task, because the user
        // can freely navigate the app (this is different from phones, where only the UP button
        // kicks the user into the full app)
        if (shouldUpRecreateTask(intent)) {
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        } else {
            intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_FORWARD_RESULT
                    | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        }
        intent.setClass(this, PeopleActivity.class);
        startActivity(intent);
        LogUtils.i(TAG, "onCreate(),Using Two Panes...finish Actiivity..");
        finish();
        return;
    }

    setContentView(R.layout.contact_detail_activity);

    mContactDetailLayoutController = new ContactDetailLayoutController(this, savedState, getFragmentManager(),
            null, findViewById(R.id.contact_detail_container), mContactDetailFragmentListener);

    // We want the UP affordance but no app icon.
    // Setting HOME_AS_UP, SHOW_TITLE and clearing SHOW_HOME does the trick.
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        ///@Modify for add Customer view{
        actionBar.setDisplayOptions(
                ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM,
                ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME
                        | ActionBar.DISPLAY_SHOW_CUSTOM);
        ///@}
        actionBar.setTitle("");
    }

    Log.i(TAG, getIntent().getData().toString());
    /** M: New Feature xxx @{ */
    //M:fix CR:ALPS00958663,disconnect to smartbook when contact screen happen JE
    if (getIntent() != null && getIntent().getData() != null) {
        mSimOrPhoneUri = getIntent().getData();
        Log.i(TAG, "mSimOrPhoneUri = " + mSimOrPhoneUri);
    } else {
        Log.e(TAG, "Get intent data error getIntent() = " + getIntent());
    }
    /// M: @ CT contacts detail history set listener{
    ExtensionManager.getInstance().getContactDetailEnhancementExtension().configActionBarExt(getActionBar(),
            ContactPluginDefault.COMMD_FOR_OP09);
    /// @}
    LogUtils.i(TAG, "[onCreate][launch]end");
}

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

private void AddSharedPreBtn() {
    final EditText edit_in = (EditText) findViewById(R.id.edit_in);
    final EditText edit_out = (EditText) findViewById(R.id.edit_out);
    Button btn_read = (Button) findViewById(R.id.btn_read);
    btn_read.setOnClickListener(new OnClickListener() {
        @Override/*from   ww  w . j  a  va  2  s .c  o m*/
        public void onClick(View v) {
            SharedPreferencesRead();
            // edit_out.setText(read());
            edit_out.setText(ReadFromSdCard());
        }
    });

    Button btn_write = (Button) findViewById(R.id.btn_write);
    btn_write.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd" + "hh:mm:ss");

            editor.putString("time", sdf.format(new Date()));
            editor.putInt("random", (int) (Math.random() * 100));
            editor.commit();

            // write(edit_in.getText().toString());
            WriteToSdCard(edit_in.getText().toString());
            edit_in.setText("");
        }
    });

    Button btn_read_sdcard = (Button) findViewById(R.id.btn_read_sdcard);
    btn_read_sdcard.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            // */
            intent.setClass(MainActivity.this, ReadSdCardActivity.class);
            // */

            startActivity(intent);
        }
    });

    Button btn_dict = (Button) findViewById(R.id.btn_dict);
    btn_dict.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            // */
            intent.setClass(MainActivity.this, DictResolvertTest.class);
            // */
            startActivity(intent);
        }
    });
}

From source file:com.aibasis.parent.adapter.MessageAdapter.java

/**
 * ?//from w  w  w .  j a  v a 2s  .c o  m
 * @param message
 * @param imageView
 */
private void setUserAvatar(final EMMessage message, ImageView imageView) {
    if (message.direct == Direct.SEND) {
        //?
        UserUtils.setCurrentUserAvatar(context, imageView);
    } else {
        UserUtils.setUserAvatar(context, message.getFrom(), imageView);
    }
    imageView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setClass(context, UserProfileActivity.class);
            intent.putExtra("username", message.getFrom());
            context.startActivity(intent);
        }
    });
}

From source file:cn.hbm.superwechat.adapter.MessageAdapter.java

/**
 * Super?/*www.java2  s  .c o m*/
 *
 * @param message
 * @param imageView
 */
private void setUserAvatar(final EMMessage message, ImageView imageView) {
    if (message.direct == Direct.SEND) {
        //?
        UserUtils.setMyUserAvatar(context, imageView);
    } else {
        UserUtils.setUserAvatar(context, message.getFrom(), imageView);
    }
    imageView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setClass(context, UserProfileActivity.class);
            intent.putExtra("username", message.getFrom());
            intent.putExtra("groupId", message.getFrom());
            context.startActivity(intent);
        }
    });
}

From source file:cn.ucai.fulicenter.adapter.MessageAdapter.java

/**
 * ?/*from   w  w w  .  j  a  v  a  2 s  .c o  m*/
 * @param message
 * @param imageView
 */
private void setUserAvatar(final EMMessage message, NetworkImageView imageView) {
    if (message.direct == Direct.SEND) {
        //?
        //   UserUtils.setCurrentUserAvatar(context, imageView);
        UserUtils.setCurrentUserBeanAvatar(imageView);
    } else {
        //  UserUtils.setUserAvatar(context, message.getFrom(), imageView);
        UserUtils.setUserBeanAvatar(message.getFrom(), imageView);
        //UserBean member = UserUtils.getGroupMemberInfo(username, message.getFrom());
        //UserUtils.setUserBeanAvatar(member,imageView);
    }
    imageView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setClass(context, UserProfileActivity.class);
            intent.putExtra("username", message.getFrom());
            context.startActivity(intent);
        }
    });
}

From source file:cn.ucai.superwechat.adapter.MessageAdapter.java

/**
 * ?//w w  w .j ava  2  s . c  o m
 * @param message
 * @param imageView
 */
private void setUserAvatar(final EMMessage message, ImageView imageView) {
    if (message.direct == Direct.SEND) {
        //?
        UserUtils.setCurrentUserAvatar(context, imageView);
    } else {
        UserUtils.setAppUserAvatar(context, message.getFrom(), imageView);
    }
    imageView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setClass(context, UserProfileActivity.class);
            intent.putExtra("username", message.getFrom());
            intent.putExtra("groupId", username);
            context.startActivity(intent);
        }
    });
}

From source file:com.google.samples.apps.iosched.session.SessionDetailModel.java

private void amendCalendarAndSetUpNotificationIfRequired() {
    if (!hasSessionStarted()) {
        Intent intent;
        if (mInSchedule) {
            intent = new Intent(SessionCalendarService.ACTION_ADD_SESSION_CALENDAR, mSessionUri);
            intent.putExtra(SessionCalendarService.EXTRA_SESSION_START, mSessionStart);
            intent.putExtra(SessionCalendarService.EXTRA_SESSION_END, mSessionEnd);
            intent.putExtra(SessionCalendarService.EXTRA_SESSION_ROOM, mRoomName);
            intent.putExtra(SessionCalendarService.EXTRA_SESSION_TITLE, mTitle);
        } else {// ww w. ja  v a  2s.co m
            intent = new Intent(SessionCalendarService.ACTION_REMOVE_SESSION_CALENDAR, mSessionUri);
            intent.putExtra(SessionCalendarService.EXTRA_SESSION_START, mSessionStart);
            intent.putExtra(SessionCalendarService.EXTRA_SESSION_END, mSessionEnd);
            intent.putExtra(SessionCalendarService.EXTRA_SESSION_TITLE, mTitle);
        }
        intent.setClass(mContext, SessionCalendarService.class);
        mContext.startService(intent);

        if (mInSchedule) {
            setUpNotification();
        }
    }
}

From source file:com.android.calendar.AllInOneActivity.java

@Override
public void handleEvent(EventInfo event) {
    long displayTime = -1;
    if (event.eventType == EventType.GO_TO) {
        if ((event.extraLong & CalendarController.EXTRA_GOTO_BACK_TO_PREVIOUS) != 0) {
            mBackToPreviousView = true;//from  w  ww. jav a 2  s  .c  o m
        } else if (event.viewType != mController.getPreviousViewType() && event.viewType != ViewType.EDIT) {
            // Clear the flag is change to a different view type
            mBackToPreviousView = false;
        }

        setMainPane(null, R.id.main_pane, event.viewType, event.startTime.toMillis(false), false);
        if (mSearchView != null) {
            mSearchView.clearFocus();
        }
        if (mShowCalendarControls) {
            int animationSize = (mOrientation == Configuration.ORIENTATION_LANDSCAPE) ? mControlsAnimateWidth
                    : mControlsAnimateHeight;
            boolean noControlsView = event.viewType == ViewType.MONTH || event.viewType == ViewType.AGENDA;
            if (mControlsMenu != null) {
                mControlsMenu.setVisible(!noControlsView);
                mControlsMenu.setEnabled(!noControlsView);
            }
            if (noControlsView || mHideControls) {
                // hide minimonth and calendar frag
                mShowSideViews = false;
                if (!mHideControls) {
                    final ObjectAnimator slideAnimation = ObjectAnimator.ofInt(this, "controlsOffset", 0,
                            animationSize);
                    slideAnimation.addListener(mSlideAnimationDoneListener);
                    slideAnimation.setDuration(mCalendarControlsAnimationTime);
                    ObjectAnimator.setFrameDelay(0);
                    slideAnimation.start();
                } else {
                    mMiniMonth.setVisibility(View.GONE);
                    mCalendarsList.setVisibility(View.GONE);
                    mMiniMonthContainer.setVisibility(View.GONE);
                }
            } else {
                // show minimonth and calendar frag
                mShowSideViews = true;
                mMiniMonth.setVisibility(View.VISIBLE);
                mCalendarsList.setVisibility(View.VISIBLE);
                mMiniMonthContainer.setVisibility(View.VISIBLE);
                if (!mHideControls && (mController.getPreviousViewType() == ViewType.MONTH
                        || mController.getPreviousViewType() == ViewType.AGENDA)) {
                    final ObjectAnimator slideAnimation = ObjectAnimator.ofInt(this, "controlsOffset",
                            animationSize, 0);
                    slideAnimation.setDuration(mCalendarControlsAnimationTime);
                    ObjectAnimator.setFrameDelay(0);
                    slideAnimation.start();
                }
            }
        }
        displayTime = event.selectedTime != null ? event.selectedTime.toMillis(true)
                : event.startTime.toMillis(true);
        if (!mIsTabletConfig) {
            refreshActionbarTitle(displayTime);
        }
    } else if (event.eventType == EventType.VIEW_EVENT) {

        // If in Agenda view and "show_event_details_with_agenda" is "true",
        // do not create the event info fragment here, it will be created by the Agenda
        // fragment

        if (mCurrentView == ViewType.AGENDA && mShowEventDetailsWithAgenda) {
            if (event.startTime != null && event.endTime != null) {
                // Event is all day , adjust the goto time to local time
                if (event.isAllDay()) {
                    Utils.convertAlldayUtcToLocal(event.startTime, event.startTime.toMillis(false), mTimeZone);
                    Utils.convertAlldayUtcToLocal(event.endTime, event.endTime.toMillis(false), mTimeZone);
                }
                mController.sendEvent(this, EventType.GO_TO, event.startTime, event.endTime, event.selectedTime,
                        event.id, ViewType.AGENDA, CalendarController.EXTRA_GOTO_TIME, null, null);
            } else if (event.selectedTime != null) {
                mController.sendEvent(this, EventType.GO_TO, event.selectedTime, event.selectedTime, event.id,
                        ViewType.AGENDA);
            }
        } else {
            // TODO Fix the temp hack below: && mCurrentView !=
            // ViewType.AGENDA
            if (event.selectedTime != null && mCurrentView != ViewType.AGENDA) {
                mController.sendEvent(this, EventType.GO_TO, event.selectedTime, event.selectedTime, -1,
                        ViewType.CURRENT);
            }
            int response = event.getResponse();
            if ((mCurrentView == ViewType.AGENDA && mShowEventInfoFullScreenAgenda)
                    || ((mCurrentView == ViewType.DAY || (mCurrentView == ViewType.WEEK)
                            || mCurrentView == ViewType.MONTH) && mShowEventInfoFullScreen)) {
                // start event info as activity
                Intent intent = new Intent(Intent.ACTION_VIEW);
                Uri eventUri = ContentUris.withAppendedId(Events.CONTENT_URI, event.id);
                intent.setData(eventUri);
                intent.setClass(this, EventInfoActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                intent.putExtra(EXTRA_EVENT_BEGIN_TIME, event.startTime.toMillis(false));
                intent.putExtra(EXTRA_EVENT_END_TIME, event.endTime.toMillis(false));
                intent.putExtra(ATTENDEE_STATUS, response);
                startActivity(intent);
            } else {
                // start event info as a dialog
                EventInfoFragment fragment = new EventInfoFragment(this, event.id,
                        event.startTime.toMillis(false), event.endTime.toMillis(false), response, true,
                        EventInfoFragment.DIALOG_WINDOW_STYLE, null /* No reminders to explicitly pass in. */);
                fragment.setDialogParams(event.x, event.y, mActionBar.getHeight());
                FragmentManager fm = getFragmentManager();
                FragmentTransaction ft = fm.beginTransaction();
                // if we have an old popup replace it
                Fragment fOld = fm.findFragmentByTag(EVENT_INFO_FRAGMENT_TAG);
                if (fOld != null && fOld.isAdded()) {
                    ft.remove(fOld);
                }
                ft.add(fragment, EVENT_INFO_FRAGMENT_TAG);
                ft.commit();
            }
        }
        displayTime = event.startTime.toMillis(true);
    } else if (event.eventType == EventType.UPDATE_TITLE) {
        setTitleInActionBar(event);
        if (!mIsTabletConfig) {
            refreshActionbarTitle(mController.getTime());
        }
    }
    updateSecondaryTitleFields(displayTime);
}

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

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Intent intent;
    try {/*from w  ww.  j  av a2s  . c  o m*/
        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);
}