Java Code Examples for android.content.Intent.setClass()

The following are Jave code examples for showing how to use setClass() of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: aos-Video   File: Browser.java   View Source Code Vote up 7 votes
protected void getMissingSubtitles(boolean force,ArrayList<String> allVideoPaths, ArrayList<String> missingSubVideoPaths){
    ArrayList<String> videoPaths;
    if(!force)
        videoPaths = missingSubVideoPaths;
    else
        videoPaths = allVideoPaths;
    if (videoPaths.isEmpty()&&!force){
        mDialogForceDlSubtitles = new DialogForceDlSubtitles();

        Bundle args = new Bundle();
        args.putSerializable(SubtitlesDownloaderActivity.FILE_URLS, allVideoPaths);
        mDialogForceDlSubtitles.setArguments(args);
        mDialogForceDlSubtitles.show(getFragmentManager(), null);
    }else {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.setClass(mContext, SubtitlesDownloaderActivity.class);
        intent.putExtra(SubtitlesDownloaderActivity.FILE_URLS, videoPaths);
        startActivity(intent);
    }
}
 
Example 2
Project: EasyReader   File: NBAFragment.java   View Source Code Vote up 7 votes
private void startNBADetailActivity(String id, String imgUrl, View view) {
    Intent intent = new Intent();
    intent.setClass(getActivity(), NBAActivity.class);
    intent.putExtra("id", id);
    intent.putExtra("url", imgUrl);
    /**
     * 用这个ActivityOptionsCompat比用ActivityOptions兼容性更好,前者是V4下的兼容到16后者到21.
     * ActivityOptionsCompat.makeSceneTransitionAnimation()的第三个参数则是跳转后图片显示的transitionName的值
     *     <android.support.design.widget.AppBarLayout
     android:transitionName="zhihu_detail_title"
     android:fitsSystemWindows="true">
     */
    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),
            view, getActivity().getResources().getString(R.string.zhihu_detail_title));
    getActivity().startActivity(intent, options.toBundle());
}
 
Example 3
Project: android-project-gallery   File: SplashActivity.java   View Source Code Vote up 6 votes
/**
 * Go to lock activity.
 */
private void gotoLockViewActivity()
{
	Intent intent = new Intent();
	intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	intent.setClass(this, LockViewActivity.class);
	intent.setAction(LockViewActivity.ACTION_LOCK_DECODE);
	startActivity(intent);
	
	finish();
}
 
Example 4
Project: GitHub   File: LikeAdapter.java   View Source Code Vote up 6 votes
public void gotoGirlDetail(String url,String id) {
    Intent intent = new Intent();
    intent.setClass(mContext, GirlDetailActivity.class);
    intent.putExtra("url",url);
    intent.putExtra("id",id);
    mContext.startActivity(intent);
}
 
Example 5
Project: boohee_v5.6   File: SportCourseChangeActivity.java   View Source Code Vote up 6 votes
public static void comeOnBaby(Context context) {
    if (context != null) {
        Intent intent = new Intent();
        intent.setClass(context, SportCourseChangeActivity.class);
        context.startActivity(intent);
    }
}
 
Example 6
Project: Bigbang   File: CropImage.java   View Source Code Vote up 6 votes
/**
 * Get {@link CropImageActivity} intent to start the activity.
 */
public Intent getIntent(@NonNull Context context, @Nullable Class<?> cls) {
    mOptions.validate();

    Intent intent = new Intent();
    intent.setClass(context, cls);
    intent.putExtra(CROP_IMAGE_EXTRA_SOURCE, mSource);
    intent.putExtra(CROP_IMAGE_EXTRA_OPTIONS, mOptions);
    return intent;
}
 
Example 7
Project: android-project-gallery   File: DownloadService.java   View Source Code Vote up 6 votes
/**
 * 开始下载
 * 
 * @param context
 * @param title
 * @param icon
 */
private void notifyDownloadStart(Context context, Request request)
{
	RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.api_download_notification);
	remoteViews.setProgressBar(R.id.noti_progressBar, PROGRESSBAR_MAX, 0, false);
	remoteViews.setImageViewResource(R.id.noti_icon, R.drawable.notification_remote_icon);
	remoteViews.setTextViewText(R.id.noti_file_name, request.mTitle);
	
	String host = CommonUtils.getHost(request.mDownloadUrl);
	if (CommonUtils.isWo2bHost(request.mDownloadUrl))
	{
		remoteViews.setTextViewText(R.id.noti_progressBarLeft, "www.wo2b.com");
	}
	else
	{
		remoteViews.setTextViewText(R.id.noti_progressBarLeft, host);
	}
	
	
	// 执行取消操作的PendingIntent, 向DownloadService发起取消下载的命令
	Intent cancelIntent = new Intent();
	cancelIntent.setClass(context, DownloadService.class);
	cancelIntent.putExtra(DownloadService.EXTRA_EVENT_TYPE, DownloadService.EVENT_CANCEL);
	cancelIntent.putExtra(DownloadService.EXTRA_DOWNLOAD_URL, request.mDownloadUrl);

	PendingIntent cancelPendingIntent = PendingIntent.getService(context, 100, cancelIntent,
			PendingIntent.FLAG_CANCEL_CURRENT);
	remoteViews.setOnClickPendingIntent(R.id.noti_cancel, cancelPendingIntent);
	
	// 消息信息设置
	Notification notification = new Notification();
	notification.tickerText = request.mTitle;
	notification.icon = R.drawable.notification_icon;
	notification.contentView = remoteViews;
	// notification.flags = Notification.FLAG_AUTO_CANCEL;
	notification.flags = Notification.FLAG_ONGOING_EVENT;

	// 点击通知栏
	Intent intent = new Intent();
	intent.setAction("com.wo2b.download.AActivity");
	// intent.setClass(context, Download.class);

	notification.contentIntent = PendingIntent.getActivity(context, 1, intent, PendingIntent.FLAG_CANCEL_CURRENT);
	
	// 生成通知ID
	int notificationId = new Random().nextInt(10000);

	mNotificationManager.notify(notificationId, notification);
	
	request.mNotification = notification;
	request.mNotificationId = notificationId;

}
 
Example 8
Project: DeeplinkRouter   File: DPRouter.java   View Source Code Vote up 6 votes
private static boolean innerStartActivity(Context context, Mapping mapping, Uri uri, String url, boolean isDeeplink)
{
    if(mapping.getTargetActivity() == null) return false;

    Intent intent = new Intent();

    intent.setClass(context, mapping.getTargetActivity());

    intent.setData(uri);

    intent.putExtras(mapping.parseExtras(url));

    if(!(context instanceof Activity))
    {
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    }

    context.startActivity(intent);

    ActivityRoutingStatus activityRoutingStatus = mActivityRoutingStatusMap.get(mapping.getTargetActivity());

    if(activityRoutingStatus == null)
    {
        mActivityRoutingStatusMap.put(mapping.getTargetActivity(), new ActivityRoutingStatus(isDeeplink, mapping.getParentActivityHost()));
    }
    else
    {
        activityRoutingStatus.isActivityLinkedByDeeplink = true;
    }

    return true;
}
 
Example 9
Project: q-mail   File: MailService.java   View Source Code Vote up 6 votes
public static void actionReschedulePoll(Context context, Integer wakeLockId) {
    Intent i = new Intent();
    i.setClass(context, MailService.class);
    i.setAction(MailService.ACTION_RESCHEDULE_POLL);
    addWakeLockId(context, i, wakeLockId, true);
    Utils.startServicePossiblyInForeground(context, i);
}
 
Example 10
Project: android-project-gallery   File: SplashActivity.java   View Source Code Vote up 6 votes
/**
 * Go to guide activity.
 */
private void gotoWelcomeActivity()
{
	Intent intent = new Intent();
	intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	intent.setClass(this, WelcomeActivity.class);
	startActivity(intent);
	
	finish();
}
 
Example 11
Project: YiZhi   File: BaseCompatActivity.java   View Source Code Vote up 6 votes
/**
 * [含有Bundle通过Class打开编辑界面]
 *
 * @param clz         要跳转的Activity
 * @param bundle      bundel数据
 * @param requestCode requestCode
 */
public void startActivityForResult(Class<?> clz, Bundle bundle,
                                   int requestCode) {
    Intent intent = new Intent();
    intent.setClass(this, clz);
    if (bundle != null) {
        intent.putExtras(bundle);
    }
    startActivityForResult(intent, requestCode);
    if (isTransAnim)
        overridePendingTransition(R.anim.activity_start_zoom_in, R.anim
                .activity_start_zoom_out);
}
 
Example 12
Project: InstaTag   File: InstaActivity.java   View Source Code Vote up 6 votes
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.tag_a_photo:
            Intent photoToBeTagged = new Intent(Intent.ACTION_PICK,
                    android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            startActivityForResult(photoToBeTagged, CHOOSE_A_PHOTO_TO_BE_TAGGED);
            break;
        case R.id.see_tagged_photos:
            if (!InstaTagSampleApplication.getInstance().getTaggedPhotos().isEmpty()) {
                Intent taggedPhotos = new Intent();
                taggedPhotos.setClass(InstaActivity.this, TaggedPhotoActivity.class);
                startActivity(taggedPhotos);
            } else {
                Toast.makeText(this, NO_PHOTO_TAGGED, Toast.LENGTH_SHORT).show();
            }
            break;
        case R.id.see_some_ones:
            Intent someOnes = new Intent();
            someOnes.setClass(InstaActivity.this, SomeOneActivity.class);
            startActivity(someOnes);
            break;
        case R.id.drag_test:
            Intent dragTest = new Intent();
            dragTest.setClass(InstaActivity.this, DragTestActivity.class);
            startActivity(dragTest);
            break;
        default:
            break;
    }
}
 
Example 13
Project: Bigbang   File: ScreenCaptureTile.java   View Source Code Vote up 6 votes
@Override
public void onClick() {
    Intent intent = new Intent();
    intent.setClass(this, ScreenCaptureActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivityAndCollapse(intent);
}
 
Example 14
Project: Edu   File: VideoDetailActivity.java   View Source Code Vote up 5 votes
public static void start(Context context, String id) {
    Intent intent = new Intent();
    intent.putExtra("id", id);
    intent.setClass(context, VideoDetailActivity.class);
    context.startActivity(intent);
}
 
Example 15
Project: decoy   File: AdvancedTeamInfoActivity.java   View Source Code Vote up 5 votes
public static void start(Context context, String tid) {
    Intent intent = new Intent();
    intent.putExtra(EXTRA_ID, tid);
    intent.setClass(context, AdvancedTeamInfoActivity.class);
    context.startActivity(intent);
}
 
Example 16
Project: gym-tracker-infineon   File: AIDialogSampleActivity.java   View Source Code Vote up 5 votes
@Override
        public void onSensorDataReceived(SensorHub sensorHub, SensorEvent sensorEvent) {
            if(sensor_started) {
                if (!sensorEvent.getDataId().equals("a"))
                    return;
                RelAltitude.updateValue(sensorEvent.getSensorValue());
                tv_rel_altitude.setText(String.format("Rel Pos = %.2f", RelAltitude.getRelativeValue()));
                if (exercise_list.get(log_idx).cal.State) {
                    if (abs(RelAltitude.getRelativeValue()) <= exercise_list.get(log_idx).cal.threshold_min) {
                        Integer idx = exercise_list.get(log_idx).set_log_idx;
                        RelAltitude.reset();
                        exercise_list.get(log_idx).cal.State = false;
                        Integer count = exercise_list.get(log_idx).log_info.get(idx).reps;
                        //  for some reason I cannot do reps++
                        count = count + 1;
                        exercise_list.get(log_idx).log_info.get(idx).reps = count;
                        FillPerfReps(count);
                        Integer goal = exercise_list.get(log_idx).reps_info.get(idx).reps;
                        Log.i(TAG, "REPS: " + count.toString());
                        SetCounter.setText(count.toString());
                        if (count.equals(goal)) {
                            Log.i(TAG, "Set completed");
                            TTS.speak("good you are done!");
                            sensor_started = false;
                            idx = idx + 1;
                            // we cancel the timer since we completed the set
                            set_timer.cancel();
                            if(exercise_list.get(log_idx).reps_info.size() > idx){
                                // next time we need to log in the correct position (next Set)
                                exercise_list.get(log_idx).set_log_idx = idx;
                                Log.i(TAG, "There are pending sets");
                                TTS.speak("You have more sets to do, let me know when you are ready!");
                            }else{
                                // it means we  are done with exercise sets
                                exercise_list.get(log_idx).done = true;
                                if(log_idx >= exercise_list.size() - 1) {
                                    // it means we are done with last workout exercise
                                    workout_done = true;
                                    Log.i(TAG, "Finish the workout");
                                    TTS.speak("Glad you are done, go to rest and remember " +
                                              "Winners Train, Losers Complain ");
                                    final Intent mServiceIntent = new Intent();
                                    mServiceIntent.setClass(AIDialogSampleActivity.this, RSSPullService.class);
                                    String jsonLog = getJsonLog(exercise_list);
                                    mServiceIntent.putExtra("logData", jsonLog);
                                    AIDialogSampleActivity.this.startService(mServiceIntent);
                                }else{
                                    log_idx = log_idx + 1;
                                    if(!exercise_list.get(log_idx).done) {
                                        // proceed if exercise was not previously performed (just to be sure)
                                        FillWorkoutTable(log_idx); // Fill the table with exercise to perform
                                        Log.i(TAG, "Display next exercise");
                                        TTS.speak("You finish your " + exercise_list.get(log_idx-1).name + " sets");
                                        TTS.speak("Next exercise is " + exercise_list.get(log_idx).name );
                                    }
                                }
                            }
                            // this seems to not work here
//                        sensorHub.setSelectedSensor(sensorHub.getSensorList().get(0).getId());
//                        sensorHub.stop();
                        }
                    }
                } else {
                    // Initial state
                    if (abs(RelAltitude.getRelativeValue()) >= exercise_list.get(log_idx).cal.threshold_max) {
                        exercise_list.get(log_idx).cal.State = true;
                    }
                }
            } // if started
            else
            {
                tv_rel_altitude.setText("");
                SetCounter.setText("");
            }
        }
 
Example 17
Project: musicplayer   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.toolbar_btn1:
            updateToolBarUi(0);
            mainViewPager.setCurrentItem(0);
            break;
        case R.id.toolbar_btn4:
            Intent intent1 = new Intent();
            intent1.setClass(MainActivity.this, SearchActivity.class);
            startActivity(intent1);
            break;
        case R.id.toolbar_btn3:
            updateToolBarUi(2);
            mainViewPager.setCurrentItem(3);
            break;
        case R.id.list_opera_layout:
            if (globalVariable.getMusicPosition() >= 0) {
                Intent intent = new Intent();
                intent.setClass(MainActivity.this, MusicPlayerActivity.class);
                startActivity(intent);
            } else {
                Toast.makeText(MainActivity.this, "请选择一首歌", Toast.LENGTH_SHORT).show();
            }

            break;
        case list_btn_prev:
            musicPlayerActivity.previous();
            break;
        case list_btn_play:
            if(musicPlayerService.getIsPlaying()){
                bt_play.setBackgroundResource(R.drawable.list_play_narmal);
            }else {
                bt_play.setBackgroundResource(R.drawable.list_pause_normal);
            }
            musicPlayerActivity.playOrpause();


            break;
        case list_btn_next:
            musicPlayerActivity.next();
            break;
        default:
            break;
    }
}
 
Example 18
Project: Android-lifecycle-listener   File: ActivityLifecycle.java   View Source Code Vote up 5 votes
public static void launch(Context context) {
	Intent intent = new Intent();
	intent.setClass(context, ActivityLifecycle.class);
	context.startActivity(intent);
}
 
Example 19
Project: MeetMusic   File: WelcomeActivity.java   View Source Code Vote up 5 votes
private void startMusicActivity() {
    Intent intent = new Intent();
    intent.setClass(this, HomeActivity.class);
    startActivity(intent);
    finish();
}
 
Example 20
Project: CommonItemDecoration   File: MainActivity.java   View Source Code Vote up 5 votes
private void onLinearRecyclerClick() {
    Intent it = new Intent();
    it.setClass(this, LinearActivity.class);
    startActivity(it);
}