List of usage examples for android.content Intent setClass
public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls)
From source file:com.miz.mizuu.fragments.ShowEpisodeDetailsFragment.java
private void identifyEpisode() { Intent i = new Intent(); i.setClass(getActivity(), IdentifyTvShow.class); i.putExtra("rowId", thisEpisode.getRowId()); i.putExtra("files", new String[] { thisEpisode.getFullFilepath() }); i.putExtra("isShow", false); startActivity(i);/*from w ww . j a v a2s .c o m*/ }
From source file:jieehd.villain.updater.VillainUpdater.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.view: Intent intent = new Intent(); intent.setClass(getApplicationContext(), getfiles.class); startActivity(intent);/*from w w w.ja v a 2 s . co m*/ break; case R.id.settings: Intent settings = new Intent(); settings.setClass(getApplicationContext(), villainsettings.class); Intent settingsActivity = new Intent(getBaseContext(), villainsettings.class); startActivity(settingsActivity); break; case R.id.exit: finish(); System.exit(0); break; case R.id.refresh: new Read().execute(); break; } return true; }
From source file:com.jgkj.bxxc.fragment.IndexFragment.java
@Override public void onClick(View v) { fragmentManager = getFragmentManager(); transaction = fragmentManager.beginTransaction(); license_Text_Fragment1 = new License_Text_Fragment(); license_Text_Fragment2 = new License_Text_Fragment(); Intent intent = new Intent(); switch (v.getId()) { case R.id.use_guide: //??? intent.setClass(getActivity(), UseGuideActivity.class); startActivity(intent);/* ww w .j a va 2 s. co m*/ break; case R.id.car_pickup: //? intent.setClass(getActivity(), CarPickUpActivity.class); startActivity(intent); break; case R.id.select_coach: // //?? intent.setAction("tiaozhuang"); getActivity().sendBroadcast(intent); break; case R.id.select_place: // intent.setClass(getActivity(), PlaceChooseActivity.class); intent.putExtra("uid", uid); intent.putExtra("token", token); startActivity(intent); break; case R.id.headlines: if (headlines.getTag().toString().equals("nourl")) { Toast.makeText(getActivity(), ",???!", Toast.LENGTH_SHORT).show(); } else { intent.setClass(getActivity(), WebViewActivity.class); intent.putExtra("url", headlines.getTag().toString()); intent.putExtra("title", "?"); startActivity(intent); } break; case R.id.bxhead: Intent bxheadIntent = new Intent(); bxheadIntent.setClass(getActivity(), HeadlinesActivity.class); startActivity(bxheadIntent); break; case R.id.quesAns: // intent.setClass(getActivity(), QuesAnsActivity.class); startActivity(intent); break; case R.id.bxCenter: // intent.setClass(getActivity(), BXCenterActivity.class); startActivity(intent); break; case R.id.yQfirend: //? if (userInfo == null) { intent.setClass(getActivity(), LoginActivity.class); intent.putExtra("message", "ivatationFriends"); startActivity(intent); } else { intent.setClass(getActivity(), InviteFriendsActivity.class); startActivity(intent); } break; case R.id.linear_driving_companion: // intent.setClass(getActivity(), DrivingCompanionActivity.class); startActivity(intent); break; case R.id.private_coach: if (userInfo == null) { intent.setClass(getActivity(), LoginActivity.class); intent.putExtra("message", "privateCoach"); startActivity(intent); } else { intent.setClass(getActivity(), PrivateActivity.class); startActivity(intent); } break; case R.id.remind: new CallDialog(getActivity(), "17756086205").call(); break; case R.id.txt_place: new RemainBaseDialog(getActivity(), "???").call(); break; } }
From source file:com.farmerbb.taskbar.MainActivity.java
private void proceedWithAppLaunch(Bundle savedInstanceState) { setContentView(R.layout.main);/*from w w w .java 2 s.c o m*/ ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setCustomView(R.layout.switch_layout); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM); } theSwitch = (SwitchCompat) findViewById(R.id.the_switch); if (theSwitch != null) { final SharedPreferences pref = U.getSharedPreferences(this); theSwitch.setChecked(pref.getBoolean("taskbar_active", false)); theSwitch.setOnCheckedChangeListener((compoundButton, b) -> { if (b) { if (U.canDrawOverlays(this)) { boolean firstRun = pref.getBoolean("first_run", true); startTaskbarService(); if (firstRun && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !U.isSystemApp(this)) { ApplicationInfo applicationInfo = null; try { applicationInfo = getPackageManager().getApplicationInfo(BuildConfig.APPLICATION_ID, 0); } catch (PackageManager.NameNotFoundException e) { /* Gracefully fail */ } if (applicationInfo != null) { AppOpsManager appOpsManager = (AppOpsManager) getSystemService( Context.APP_OPS_SERVICE); int mode = appOpsManager.checkOpNoThrow(AppOpsManager.OPSTR_GET_USAGE_STATS, applicationInfo.uid, applicationInfo.packageName); if (mode != AppOpsManager.MODE_ALLOWED) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle(R.string.pref_header_recent_apps) .setMessage(R.string.enable_recent_apps) .setPositiveButton(R.string.action_ok, (dialog, which) -> { try { startActivity( new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS)); U.showToastLong(MainActivity.this, R.string.usage_stats_message); } catch (ActivityNotFoundException e) { U.showErrorDialog(MainActivity.this, "GET_USAGE_STATS"); } }).setNegativeButton(R.string.action_cancel, null); AlertDialog dialog = builder.create(); dialog.show(); } } } } else { U.showPermissionDialog(MainActivity.this); compoundButton.setChecked(false); } } else stopTaskbarService(); }); } if (savedInstanceState == null) { if (!getIntent().hasExtra("theme_change")) getFragmentManager().beginTransaction() .replace(R.id.fragmentContainer, new AboutFragment(), "AboutFragment").commit(); else getFragmentManager().beginTransaction() .replace(R.id.fragmentContainer, new AppearanceFragment(), "AppearanceFragment").commit(); } if (!BuildConfig.APPLICATION_ID.equals(BuildConfig.BASE_APPLICATION_ID) && freeVersionInstalled()) { final SharedPreferences pref = U.getSharedPreferences(this); if (!pref.getBoolean("dont_show_uninstall_dialog", false)) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.settings_imported_successfully).setMessage(R.string.import_dialog_message) .setPositiveButton(R.string.action_uninstall, (dialog, which) -> { pref.edit().putBoolean("uninstall_dialog_shown", true).apply(); try { startActivity(new Intent(Intent.ACTION_DELETE, Uri.parse("package:" + BuildConfig.BASE_APPLICATION_ID))); } catch (ActivityNotFoundException e) { /* Gracefully fail */ } }); if (pref.getBoolean("uninstall_dialog_shown", false)) builder.setNegativeButton(R.string.action_dont_show_again, (dialogInterface, i) -> pref.edit() .putBoolean("dont_show_uninstall_dialog", true).apply()); AlertDialog dialog = builder.create(); dialog.show(); dialog.setCancelable(false); } if (!pref.getBoolean("uninstall_dialog_shown", false)) { if (theSwitch != null) theSwitch.setChecked(false); SharedPreferences.Editor editor = pref.edit(); String iconPack = pref.getString("icon_pack", BuildConfig.BASE_APPLICATION_ID); if (iconPack.contains(BuildConfig.BASE_APPLICATION_ID)) { editor.putString("icon_pack", BuildConfig.APPLICATION_ID); } else { U.refreshPinnedIcons(this); } editor.putBoolean("first_run", true); editor.apply(); } } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { ShortcutManager shortcutManager = getSystemService(ShortcutManager.class); if (shortcutManager.getDynamicShortcuts().size() == 0) { Intent intent = new Intent(Intent.ACTION_MAIN); intent.setClass(this, StartTaskbarActivity.class); intent.putExtra("is_launching_shortcut", true); ShortcutInfo shortcut = new ShortcutInfo.Builder(this, "start_taskbar") .setShortLabel(getString(R.string.start_taskbar)) .setIcon(Icon.createWithResource(this, R.drawable.shortcut_icon_start)).setIntent(intent) .build(); Intent intent2 = new Intent(Intent.ACTION_MAIN); intent2.setClass(this, ShortcutActivity.class); intent2.putExtra("is_launching_shortcut", true); ShortcutInfo shortcut2 = new ShortcutInfo.Builder(this, "freeform_mode") .setShortLabel(getString(R.string.pref_header_freeform)) .setIcon(Icon.createWithResource(this, R.drawable.shortcut_icon_freeform)) .setIntent(intent2).build(); shortcutManager.setDynamicShortcuts(Arrays.asList(shortcut, shortcut2)); } } }
From source file:com.easemob.helpdeskdemo.ui.SettingFragment.java
@Override public void onClick(View v) { Intent intent = new Intent(); switch (v.getId()) { case R.id.ll_setting_list_appkey: String strAppkey = tvAppkey.getText().toString(); intent.setClass(getActivity(), ModifyActivity.class); intent.putExtra(Constant.MODIFY_ACTIVITY_INTENT_INDEX, Constant.MODIFY_INDEX_APPKEY); intent.putExtra(Constant.MODIFY_ACTIVITY_INTENT_CONTENT, strAppkey); startActivityForResult(intent, REQUEST_CODE_APPKEY); break;/* w w w . j a va 2s.c o m*/ case R.id.ll_setting_list_account: String strAccount = tvAccount.getText().toString(); intent.setClass(getActivity(), ModifyActivity.class); intent.putExtra(Constant.MODIFY_ACTIVITY_INTENT_INDEX, Constant.MODIFY_INDEX_ACCOUNT); intent.putExtra(Constant.MODIFY_ACTIVITY_INTENT_CONTENT, strAccount); startActivityForResult(intent, REQUEST_CODE_ACCOUNT); break; case R.id.ll_setting_list_nick: String strNick = tvNick.getText().toString(); intent.setClass(getActivity(), ModifyActivity.class); intent.putExtra(Constant.MODIFY_ACTIVITY_INTENT_INDEX, Constant.MODIFY_INDEX_NICK); intent.putExtra(Constant.MODIFY_ACTIVITY_INTENT_CONTENT, strNick); startActivityForResult(intent, REQUEST_CODE_NICK); break; case R.id.ll_setting_tenant_id: String strTenantId = tvTenantId.getText().toString(); intent.setClass(getActivity(), ModifyActivity.class); intent.putExtra(Constant.MODIFY_ACTIVITY_INTENT_INDEX, Constant.MODIFY_INDEX_TENANT_ID); intent.putExtra(Constant.MODIFY_ACTIVITY_INTENT_CONTENT, strTenantId); startActivityForResult(intent, REQUEST_CODE_TENANT_ID); break; case R.id.ll_setting_project_id: String strProjectId = tvProjectId.getText().toString(); intent.setClass(getActivity(), ModifyActivity.class); intent.putExtra(Constant.MODIFY_ACTIVITY_INTENT_INDEX, Constant.MODIFY_INDEX_PROJECT_ID); intent.putExtra(Constant.MODIFY_ACTIVITY_INTENT_CONTENT, strProjectId); startActivityForResult(intent, REQUEST_CODE_PROJECT_ID); break; case R.id.tv_qcode: intent.setClass(getActivity(), CaptureActivity.class); startActivityForResult(intent, REQUEST_CODE_QCODE); break; default: break; } }
From source file:com.rubika.aotalk.aou.FragmentGuides.java
@Override public void onListItemClick(ListView l, View v, int position, long id) { Logging.log(APP_TAG, "Item clicked: " + mAdapter.getItem(position).getLabel()); if (mAdapter.getItem(position).getType() == 1) { Intent intent = new Intent(); intent.setClass(mAdapter.getContext(), ActivityGuide.class); intent.putExtra("title", mAdapter.getItem(position).getLabel()); intent.putExtra("id", mAdapter.getItem(position).getID()); if (AOU.isTablet) { aou.loadFragment(intent, 2); } else {/* ww w . j a va2 s .com*/ mAdapter.getContext().startActivity(intent); } } else { mAdapter.setFolder(mAdapter.getItem(position).getID()); setListShown(false); getLoaderManager().restartLoader(0, null, this); } }
From source file:com.facebook.login.LoginManager.java
private Intent getFacebookActivityIntent(LoginClient.Request request) { Intent intent = new Intent(); intent.setClass(FacebookSdk.getApplicationContext(), FacebookActivity.class); intent.setAction(request.getLoginBehavior().toString()); // Let FacebookActivity populate extras appropriately LoginClient.Request authClientRequest = request; Bundle extras = new Bundle(); extras.putParcelable(LoginFragment.EXTRA_REQUEST, request); intent.putExtras(extras);/* w w w . j av a 2s . c o m*/ return intent; }
From source file:com.android.deskclock.timer.TimerReceiver.java
private void updateNextTimesup(Context context) { TimerObj t = getNextRunningTimer(mTimers, false, Utils.getTimeNow()); long nextTimesup = (t == null) ? -1 : t.getTimesupTime(); int timerId = (t == null) ? -1 : t.mTimerId; Intent intent = new Intent(); intent.setAction(Timers.TIMES_UP);/*from w w w . j a v a2 s .com*/ intent.setClass(context, TimerReceiver.class); // Time-critical, should be foreground intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); if (!mTimers.isEmpty()) { intent.putExtra(Timers.TIMER_INTENT_EXTRA, timerId); } AlarmManager mngr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); PendingIntent p = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT); if (t != null) { if (Utils.isKitKatOrLater()) { mngr.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextTimesup, p); } else { mngr.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextTimesup, p); } if (Timers.LOGGING) { Log.d(TAG, "Setting times up to " + nextTimesup); } } else { // if no timer is found Pending Intents should be canceled // to keep the internal state consistent with the UI mngr.cancel(p); p.cancel(); if (Timers.LOGGING) { Log.v(TAG, "no next times up"); } } }
From source file:com.asksven.commandcenter.BasicMasterFragment.java
/** * Helper function to show the details of a selected item, either by * displaying a fragment in-place in the current UI, or starting a * whole new activity in which it is displayed. *//*w w w .java2 s . co m*/ void showDetails(int key) { mCurCheckPosition = key; if (mDualPane) { // We can display everything in-place with fragments, so update // the list to highlight the selected item and show the data. getListView().setItemChecked(key, true); // Check what fragment is currently shown, replace if needed. BasicDetailsFragment details = (BasicDetailsFragment) getFragmentManager() .findFragmentById(R.id.details); if ((m_myCommand == null) || (details == null) || (details.getShownKey() != m_myCommand.getId())) { // Make new fragment to show this selection. details = BasicDetailsFragment.newInstance(key, m_strCollectionName); // Execute a transaction, replacing any existing fragment // with this one inside the frame. FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.details, details); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.commit(); } } else { // Otherwise we need to launch a new activity to display // the dialog fragment with selected text. Intent intent = new Intent(); intent.setClass(getActivity(), BasicDetailsActivity.class); intent.putExtra("index", key); intent.putExtra("collection", m_strCollectionName); startActivity(intent); } }
From source file:com.google.plus.samples.photohunt.ThemeViewActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_item_upload: startCameraIntent();//from w w w. j a v a 2 s. c o m return true; case R.id.menu_item_gallery: Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Photo"), REQUEST_CODE_IMAGE_SELECT); return true; case android.R.id.home: case R.id.menu_item_theme_select: DialogFragment themeDialog = new ThemeSelectDialog(); themeDialog.show(getSupportFragmentManager(), SELECT_THEME_TAG); return true; case R.id.menu_item_profile: Intent profileIntent = new Intent(); profileIntent.setClass(this, ProfileActivity.class); startActivity(profileIntent); return true; case R.id.menu_item_refresh: mThemeListLoader.forceLoad(); mPhotoListAdapter.setDirty(THEME_PHOTOS_ID, true); mPhotoListAdapter.setDirty(FRIEND_PHOTOS_ID, true); mPhotoListAdapter.setDirty(MY_PHOTOS_ID, true); update(); return true; case R.id.menu_item_about: Intent aboutIntent = new Intent(); aboutIntent.setClass(this, AboutActivity.class); startActivity(aboutIntent); return true; } return super.onOptionsItemSelected(item); }