List of usage examples for android.content Intent setClass
public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls)
From source file:com.sft.fragment.CoachsFragment1.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (data != null) { if (resultCode == R.id.base_left_btn) { return; }//from www . ja va 2s . c om boolean isFromEnroll = data.getBooleanExtra(from_searchCoach_enroll, false); if (isFromEnroll) { data.setClass(getActivity(), ApplyActivity.class); data.putExtra(from_searchCoach_enroll, isFromEnroll); startActivity(data); getActivity().finish(); } } }
From source file:aarddict.android.ArticleViewActivity.java
@Override public boolean onSearchRequested() { Intent intent = getIntent();// ww w . j a v a 2 s . c o m String action = intent == null ? null : intent.getAction(); if (action != null) { String word = null; if (action.equals(Intent.ACTION_SEARCH)) { word = intent.getStringExtra("query"); } else if (action.equals(Intent.ACTION_SEND)) { word = intent.getStringExtra(Intent.EXTRA_TEXT); } if (word != null) { Intent next = new Intent(); next.setClass(this, LookupActivity.class); next.setAction(Intent.ACTION_SEARCH); next.putExtra(SearchManager.QUERY, word); startActivity(next); } } finish(); return true; }
From source file:com.dahl.brendan.wordsearch.view.WordSearchActivity.java
/** when menu button option selected */ @Override/* w ww .j a v a 2 s . c o m*/ public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_scores: this.showDialog(DIALOG_ID_HIGH_SCORES_LOCAL_SHOW); return true; case R.id.menu_options: startActivity(new Intent(this, WordSearchPreferences.class)); return true; case R.id.menu_new: control.newWordSearch(); return true; case R.id.menu_custom: { Intent intent = new Intent(Intent.ACTION_EDIT, Word.CONTENT_URI); intent.setType(Word.CONTENT_TYPE); this.startActivity(intent); return true; } case R.id.menu_tutorial: { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClass(this, TutorialActivity.class); startActivity(intent); return true; } case R.id.menu_donate: { this.showDialog(DIALOG_ID_DONATE); return true; } default: return super.onOptionsItemSelected(item); } }
From source file:info.androidhive.slidingmenu.Games.WordSearch.wordsearch.view.WordSearchActivity.java
/** when menu button option selected */ @Override/*from www . j a v a 2 s .com*/ public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_scores: this.showDialog(DIALOG_ID_HIGH_SCORES_LOCAL_SHOW); return true; case R.id.menu_options: startActivity(new Intent(this, WordSearchPreferences.class)); return true; case R.id.menu_new: control.newWordSearch(); return true; case R.id.menu_custom: { Intent intent = new Intent(Intent.ACTION_EDIT, WordDictionaryProvider.Word.CONTENT_URI); intent.setType(WordDictionaryProvider.Word.CONTENT_TYPE); this.startActivity(intent); return true; } case R.id.menu_tutorial: { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClass(this, TutorialActivity.class); startActivity(intent); return true; } case R.id.menu_donate: { this.showDialog(DIALOG_ID_DONATE); return true; } default: return super.onOptionsItemSelected(item); } }
From source file:org.openremote.android.console.AppSettingsActivity.java
/** * It contains a list view to display custom servers, * "Add" button to add custom server, "Delete" button to delete custom server. * The custom servers would be saved in customServers.xml. If click a list item, it would be saved as current server. * //from w w w.j a v a 2 s .c o m * @return the linear layout */ private LinearLayout constructCustomServersView() { LinearLayout custumeView = new LinearLayout(this); custumeView.setOrientation(LinearLayout.VERTICAL); custumeView.setPadding(20, 5, 5, 0); custumeView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); ArrayList<String> customServers = new ArrayList<String>(); initCustomServersFromFile(customServers); RelativeLayout buttonsView = new RelativeLayout(this); buttonsView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 80)); Button addServer = new Button(this); addServer.setWidth(80); RelativeLayout.LayoutParams addServerLayout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); addServerLayout.addRule(RelativeLayout.CENTER_HORIZONTAL); addServer.setLayoutParams(addServerLayout); addServer.setText("Add"); addServer.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(); intent.setClass(AppSettingsActivity.this, AddServerActivity.class); startActivityForResult(intent, Constants.REQUEST_CODE); } }); Button deleteServer = new Button(this); deleteServer.setWidth(80); RelativeLayout.LayoutParams deleteServerLayout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); deleteServerLayout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); deleteServer.setLayoutParams(deleteServerLayout); deleteServer.setText("Delete"); deleteServer.setOnClickListener(new OnClickListener() { @SuppressWarnings("unchecked") public void onClick(View v) { int checkedPosition = customListView.getCheckedItemPosition(); if (!(checkedPosition == ListView.INVALID_POSITION)) { customListView.setItemChecked(checkedPosition, false); ((ArrayAdapter<String>) customListView.getAdapter()) .remove(customListView.getItemAtPosition(checkedPosition).toString()); currentServer = ""; AppSettingsModel.setCurrentServer(AppSettingsActivity.this, currentServer); writeCustomServerToFile(); } } }); buttonsView.addView(addServer); buttonsView.addView(deleteServer); customListView = new ListView(this); customListView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 200)); customListView.setCacheColorHint(0); final ArrayAdapter<String> serverListAdapter = new ArrayAdapter<String>(appSettingsView.getContext(), R.layout.server_list_item, customServers); customListView.setAdapter(serverListAdapter); customListView.setItemsCanFocus(true); customListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); if (currentCustomServerIndex != -1) { customListView.setItemChecked(currentCustomServerIndex, true); currentServer = (String) customListView.getItemAtPosition(currentCustomServerIndex); } customListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { currentServer = (String) parent.getItemAtPosition(position); AppSettingsModel.setCurrentServer(AppSettingsActivity.this, currentServer); writeCustomServerToFile(); requestPanelList(); checkAuthentication(); requestAccess(); } }); custumeView.addView(customListView); custumeView.addView(buttonsView); requestPanelList(); checkAuthentication(); requestAccess(); return custumeView; }
From source file:at.jclehner.rxdroid.DrugListActivity.java
public void onDrugNameClick(View view) { Intent intent = new Intent(Intent.ACTION_EDIT); intent.setClass(this, DrugEditActivity.class); Drug drug = Drug.get((Integer) view.getTag(TAG_DRUG_ID)); intent.putExtra(DrugEditActivity.EXTRA_DRUG_ID, drug.getId()); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); //startActivityForResult(intent, 0); startActivity(intent);/* w ww . jav a 2s.c om*/ }
From source file:com.custom.music.MusicBrowserActivity.java
/** * get current view/* w ww . j ava 2 s . co m*/ * * @param index * @return View */ private View getView(int index) { Log.i(TAG, ">>> getView index = " + index, Log.APP); View view = null; Intent intent = new Intent(Intent.ACTION_PICK); //update by zjw //Uri.EMPTY --> custom switch (index) { case ARTIST_INDEX: intent.setClass(this, ArtistAlbumBrowserActivity.class); intent.setDataAndType(Uri.EMPTY, Constants.ARTIST_MIME_TYPE); break; case ALBUM_INDEX: intent.setClass(this, AlbumBrowserActivity.class); intent.setDataAndType(Uri.EMPTY, Constants.ALBUM_MIME_TYPE); break; case SONG_INDEX: intent.setClass(this, TrackBrowserActivity.class); intent.setDataAndType(Uri.EMPTY, Constants.TRACK_MIME_TYPE); break; case PLAYLIST_INDEX: intent.setClass(this, PlaylistBrowserActivity.class); intent.setDataAndType(Uri.EMPTY, Constants.PLAYLIST_MIME_TYPE); break; default: return null; } intent.putExtra("withtabs", true); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); view = mActivityManager.startActivity(getStringId(index), intent).getDecorView(); Log.i(TAG, "getView >>>", Log.APP); return view; }
From source file:com.example.scrumptious.SelectionFragment.java
private void startPickerActivity(Uri data, int requestCode) { Intent intent = new Intent(); intent.setData(data);/*from w w w . j a v a 2s.c om*/ intent.setClass(getActivity(), PickerActivity.class); startActivityForResult(intent, requestCode); }
From source file:org.linphone.LinphoneService.java
void tryTogetLastReceive() { new Thread() { public void run() { while (receiveall) { try { String str = YaoqingNetworkUtils.noticegetLastReceiveResultForHttpGet(); JSONArray jsonArray = new JSONArray(str.toString()); // JSONObject jsonObject = new JSONObject(str.toString()); // String state = jsonObject.getString("state"); // String msg = jsonObject.getString("msg"); // Log.i(TAG, "state=" + state); // Log.i(TAG, "msg=" + msg); if (jsonArray.length() > 0) { Intent intent = new Intent(); intent.putExtra("name", "a"); intent.putExtra("mid", 0); intent.setClass(LinphoneService.this, ZhizhiYaoqingActivity.class); startActivity(intent); }/* ww w . jav a 2 s . c o m*/ } catch (ClientProtocolException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } } }; }.start(); }
From source file:com.android.providers.downloads.DownloadService.java
/** * Update {@link #mDownloads} to match {@link DownloadProvider} state. * Depending on current download state it may enqueue {@link DownloadThread} * instances, request {@link DownloadScanner} scans, update user-visible * notifications, and/or schedule future actions with {@link AlarmManager}. * <p>//from w ww .ja v a 2s .c o m * Should only be called from {@link #mUpdateThread} as after being * requested through {@link #enqueueUpdate()}. * * @return If there are active tasks being processed, as of the database * snapshot taken in this update. */ private boolean updateLocked() { final long now = mSystemFacade.currentTimeMillis(); boolean isActive = false; long nextActionMillis = Long.MAX_VALUE; final Set<Long> staleIds = Sets.newHashSet(mDownloads.keySet()); final ContentResolver resolver = getContentResolver(); Cursor cursor = null; try { cursor = resolver.query(Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI, null, null, null, null); final DownloadInfo.Reader reader = new DownloadInfo.Reader(resolver, cursor); final int idColumn = cursor.getColumnIndexOrThrow(Downloads.Impl._ID); while (cursor.moveToNext()) { final long id = cursor.getLong(idColumn); long currentDownloadNextActionMillis = Long.MAX_VALUE; DownloadInfo info = mDownloads.get(id); if (info != null) { updateDownload(reader, info, now); } else { // Check xunlei engine status when create a new task info = insertDownloadLocked(reader, now); } if (info.mDeleted) { // Delete download if requested, but only after cleaning up if (!TextUtils.isEmpty(info.mMediaProviderUri)) { resolver.delete(Uri.parse(info.mMediaProviderUri), null, null); } // if download has been completed, delete xxx, else delete xxx.midownload if (info.mStatus == Downloads.Impl.STATUS_SUCCESS) { if (info.mFileName != null) { deleteFileIfExists(info.mFileName); } } else { if (info.mFileName != null) { deleteFileIfExists(info.mFileName + Helpers.sDownloadingExtension); } } resolver.delete(info.getAllDownloadsUri(), null, null); } else { staleIds.remove(id); // Kick off download task if ready String pkg = TextUtils.isEmpty(info.mPackage) ? sUnknownPackage : info.mPackage; final boolean activeDownload = info.startDownloadIfReady(MyExecutor.getExecutorInstance(pkg)); // Kick off media scan if completed final boolean activeScan = info.startScanIfReady(mScanner); // get current download task's next action millis currentDownloadNextActionMillis = info.nextActionMillis(now); XLConfig.LOGD("Download " + info.mId + ": activeDownload=" + activeDownload + ", activeScan=" + activeScan); isActive |= activeDownload; isActive |= activeScan; // if equals 0, keep download service on. isActive |= (currentDownloadNextActionMillis == 0); } // Keep track of nearest next action nextActionMillis = Math.min(currentDownloadNextActionMillis, nextActionMillis); } } catch (SQLiteDiskIOException e) { XLConfig.LOGD("error when updateLocked: ", e); } catch (Exception e) { XLConfig.LOGD("error when updateLocked: ", e); } finally { if (cursor != null) { cursor.close(); } } // Clean up stale downloads that disappeared for (Long id : staleIds) { deleteDownloadLocked(id); } // Update notifications visible to user mNotifier.updateWith(mDownloads.values()); // Set alarm when next action is in future. It's okay if the service // continues to run in meantime, since it will kick off an update pass. if (nextActionMillis > 0 && nextActionMillis < Long.MAX_VALUE) { XLConfig.LOGD("scheduling start in " + nextActionMillis + "ms"); final Intent intent = new Intent(Constants.ACTION_RETRY); intent.setClass(this, DownloadReceiver.class); mAlarmManager.set(AlarmManager.RTC_WAKEUP, now + nextActionMillis, PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_ONE_SHOT)); } return isActive; }