List of usage examples for android.content Intent setClass
public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls)
From source file:com.guardtrax.ui.screens.HomeScreen.java
private void report_click() { AlertDialog.Builder dialog = new AlertDialog.Builder(HomeScreen.this); dialog.setTitle("Reports - Documents"); dialog.setMessage("Create Notes or review a Document?"); dialog.setPositiveButton("Notes", new DialogInterface.OnClickListener() { @Override/*ww w . j a v a 2s .com*/ public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent.setClass(HomeScreen.this, ReportScreen.class); intent.putExtra("type", "Activity Report"); intent.putExtra("incident", ""); intent.putExtra("fromFile", "no"); intent.putExtra("fileName", ""); intent.putExtra("traffic", "no"); startActivity(intent); } }); dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); dialog.setNeutralButton("Documents", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent.setClass(HomeScreen.this, PostOrderScreen.class); if (new_document) { animation.cancel(); new_document = false; intent.putExtra("new_document", Utility.getlastDocument()); } startActivity(intent); } }); dialog.show(); }
From source file:com.xmobileapp.rockplayer.RockPlayer.java
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { /*/*from w w w . java 2 s .c o m*/ * Shuffle */ case 0: if (this.SHUFFLE) this.SHUFFLE = false; else this.SHUFFLE = true; try { playerServiceIface.setShuffle(this.SHUFFLE); } catch (RemoteException e) { e.printStackTrace(); } RockOnPreferenceManager settings = new RockOnPreferenceManager(FILEX_PREFERENCES_PATH); settings.putBoolean("Shuffle", this.SHUFFLE); return true; /* * Search */ case 1: if (GRATIS) { showLitePopup(); return true; } //this.hideMainUI(); this.showSongSearch(); this.songSearchTextView.requestFocus(); Cursor allSongsCursor = contentResolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, SONG_COLS, // we should minimize the number of columns null, // all songs null, // parameters to the previous parameter - which is null also null // sort order, SQLite-like ); SimpleCursorAdapter songAdapter = new SimpleCursorAdapter(this, R.layout.simple_dropdown_item_2line, allSongsCursor, new String[] { MediaStore.Audio.Media.TITLE, MediaStore.Audio.Media.ARTIST }, new int[] { R.id.text1, R.id.text2 }); FilterQueryProvider songSearchFilterProvider = new FilterQueryProvider() { @Override public Cursor runQuery(CharSequence constraint) { String whereClause = MediaStore.Audio.Media.TITLE + " LIKE '%" + constraint + "%'" + " OR " + MediaStore.Audio.Media.ARTIST + " LIKE '%" + constraint + "%'"; Log.i("SEARCH", whereClause); //whereClause = null; Cursor songsCursor = contentResolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, SONG_COLS, // we should minimize the number of columns whereClause, // songs where the title or artist name matches null, // parameters to the previous parameter - which is null also null // sort order, SQLite-like ); return songsCursor; } }; songAdapter.setFilterQueryProvider(songSearchFilterProvider); this.songSearchTextView.setAdapter(songAdapter); songAdapter .setStringConversionColumn(allSongsCursor.getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE)); //this.songSearchTextView.setOnKeyListener(songSearchKeyListener); return true; /* * Share */ case 5: if (GRATIS) { showLitePopup(); return true; } ShareSong shareSong = new ShareSong(context, songCursor); shareSong.shareByMail(); return true; /* * Get Art */ case 3: // if(GRATIS){ // showLitePopup(); // return true; // } albumReloadProgressDialog = new ProgressDialog(this); albumReloadProgressDialog.setIcon(R.drawable.ic_menu_music_library); albumReloadProgressDialog.setTitle("Loading Album Art"); albumReloadProgressDialog.setMessage("Waiting for Last.FM connection"); // TODO: set powered by Last.FM albumReloadProgressDialog.show(); Thread albumArtThread = new Thread() { public void run() { try { LastFmAlbumArtImporter lastFmArtImporter = new LastFmAlbumArtImporter(context); lastFmArtImporter.getAlbumArt(); } catch (Exception e) { e.printStackTrace(); } } }; //albumArtThread.setUncaughtExceptionHandler(albumArtUncaughtExceptionHandler); albumArtThread.start(); //containerLayout.addView(albumReloadProgressDialog); return true; /* * Concerts */ case 4: if (GRATIS) { showLitePopup(); return true; } this.hideMainUI(); this.mainUIContainer.setVisibility(View.GONE); //this.hideHelpUI(); this.showEventUI(); /* * Concert Radius Thing */ // TODO: need a metric // SharedPreferences prefs = getSharedPreferences(PREFS_NAME, 0); RockOnPreferenceManager prefs = new RockOnPreferenceManager(FILEX_PREFERENCES_PATH); concertRadius = prefs.getLong("ConcertRadius", (long) (this.CONCERT_RADIUS_DEFAULT)); this.eventListRadius.setText(String.valueOf(Math.round((float) concertRadius / 1000))); /* * Show a dialog to give some nice feedback to the user */ concertAnalysisProgressDialog = new ProgressDialog(this); concertAnalysisProgressDialog.setIcon(android.R.drawable.ic_menu_today); concertAnalysisProgressDialog.setTitle("Analysing concert information"); concertAnalysisProgressDialog.setMessage("Waiting for Last.FM connection"); concertAnalysisProgressDialog.show(); /* * Analyze concert info */ lastFmEventImporter = new LastFmEventImporter(context); new Thread() { public void run() { try { lastFmEventImporter.getArtistEvents(); } catch (SAXException e) { e.printStackTrace(); } catch (ParserConfigurationException e) { e.printStackTrace(); } } }.start(); return true; /* * Playlists */ case 6: if (GRATIS) { showLitePopup(); return true; } /* * Get the views and make them visible */ String sortOrder = MediaStore.Audio.Playlists.NAME + " ASC"; Cursor playlistAllCursor = contentResolver.query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, this.PLAYLIST_COLS, null, null, sortOrder); /* * Create Array with custom playlist + system playlists */ Playlist playlistTemp; ArrayList<Playlist> playlistArray = new ArrayList<Playlist>(); /* ALL Playlist*/ playlistTemp = new Playlist(); playlistTemp.id = constants.PLAYLIST_ALL; playlistTemp.name = "All songs"; playlistArray.add(playlistTemp); /* Recently Added */ playlistTemp = new Playlist(); playlistTemp.id = constants.PLAYLIST_RECENT; playlistTemp.name = "Recently Added"; playlistArray.add(playlistTemp); /* ... other system playlists ... */ /* add every playlist in the media store */ while (playlistAllCursor.moveToNext()) { playlistTemp = new Playlist(); playlistTemp.id = playlistAllCursor .getLong(playlistAllCursor.getColumnIndexOrThrow(MediaStore.Audio.Playlists._ID)); playlistTemp.name = playlistAllCursor .getString(playlistAllCursor.getColumnIndexOrThrow(MediaStore.Audio.Playlists.NAME)); playlistArray.add(playlistTemp); Log.i("PLAYLIST MENU", playlistTemp.id + " " + playlistTemp.name); } // String[] fieldsFrom = new String[1]; // int[] fieldsTo = new int[1]; // fieldsFrom[0] = MediaStore.Audio.Playlists.NAME; // fieldsTo[0] = R.id.playlist_name; // PlaylistCursorAdapter playlistAllAdapter = new PlaylistCursorAdapter(this.getApplicationContext(), // R.layout.playlist_item, // playlistAllCursor, // fieldsFrom, // fieldsTo); PlaylistArrayAdapter playlistAllAdapter = new PlaylistArrayAdapter(getApplicationContext(), R.layout.playlist_item, playlistArray); /* * Create Dialog */ AlertDialog.Builder aD = new AlertDialog.Builder(context); aD.create(); aD.setTitle("Select Playlist"); aD.setAdapter(playlistAllAdapter, playlistDialogClickListener); aD.show(); // playlistView.setAdapter(playlistAllAdapter); // // playlistView.setOnItemClickListener(playlistItemClickListener); // /* // * Animate scroll up of the listview // */ // TranslateAnimation slideUp = new TranslateAnimation(0,0,display.getHeight(),0); // slideUp.setFillAfter(true); // slideUp.setDuration(250); // playlistContainer.startAnimation(slideUp); // //this.mainUIContainer.addView(playlistAllSpinner); return true; /* * Preferences */ case 7: if (GRATIS) { showLitePopup(); return true; } Intent i = new Intent(); i.setClass(getApplicationContext(), RockOnSettings.class); // this.recentPlaylistPeriod = getSharedPreferences(PREFS_NAME, 0) (new RockOnPreferenceManager(FILEX_PREFERENCES_PATH)).getInt(new Constants().PREF_KEY_RECENT_PERIOD, new Constants().RECENT_PERIOD_DEFAULT_IN_DAYS); startActivityForResult(i, new Constants().PREFERENCES_REQUEST); return true; /* * Help */ case 8: this.hideMainUI(); //this.mainUIContainer.setVisibility(View.GONE); this.showHelpUI(); return true; /* * Exit */ case 2: try { this.playerServiceIface.destroy(); this.finish(); } catch (Exception e) { e.printStackTrace(); } return true; } return false; }
From source file:com.cognizant.trumobi.PersonaLauncher.java
void editShirtcut(PersonaApplicationInfo info) { Intent edit = new Intent(Intent.ACTION_EDIT); edit.setClass(this, PersonaCustomShirtcutActivity.class); edit.putExtra(PersonaCustomShirtcutActivity.EXTRA_APPLICATIONINFO, info.id); startActivityForResult(edit, REQUEST_EDIT_SHIRTCUT); }
From source file:com.nest5.businessClient.Initialactivity.java
private void showSettings() { Intent intent = new Intent(); intent.setClass(mContext, SetPreferenceActivity.class); startActivityForResult(intent, 0);//www.j a v a 2 s . co m }
From source file:com.nest5.businessClient.Initialactivity.java
private void showTableLayout() { Intent intent = new Intent(); intent.setClass(mContext, TablesActivity.class); startActivityForResult(intent, RETURN_FROM_DESIGN_TABLE); }
From source file:com.nest5.businessClient.Initialactivity.java
private void showMesasLayout() { Intent intento = new Intent(); if (openTables.size() > 0) { Gson gson = new Gson(); String list = gson.toJson(openTables); intento.putExtra("mesasabiertas", list); }//w ww .j a v a 2 s. c om intento.setClass(mContext, TablesOrderActivity.class); startActivityForResult(intento, RETURN_FROM_OPENCLOSE_TABLE); }
From source file:org.getlantern.firetweet.util.Utils.java
public static boolean handleMenuItemClick(Context context, Fragment fragment, FragmentManager fm, AsyncTwitterWrapper twitter, ParcelableStatus status, MenuItem item) { switch (item.getItemId()) { case MENU_COPY: { if (ClipboardUtils.setText(context, status.text_plain)) { showOkMessage(context, R.string.text_copied, false); }//from w ww . ja v a 2s . c om break; } case MENU_RETWEET: { if (isMyRetweet(status)) { twitter.cancelRetweetAsync(status.account_id, status.id, status.my_retweet_id); } else { twitter.retweetStatusAsync(status.account_id, status.id); } break; } case MENU_QUOTE: { final Intent intent = new Intent(INTENT_ACTION_QUOTE); intent.putExtra(EXTRA_STATUS, status); context.startActivity(intent); break; } case MENU_REPLY: { final Intent intent = new Intent(INTENT_ACTION_REPLY); intent.putExtra(EXTRA_STATUS, status); context.startActivity(intent); break; } case MENU_FAVORITE: { if (status.is_favorite) { twitter.destroyFavoriteAsync(status.account_id, status.id); } else { twitter.createFavoriteAsync(status.account_id, status.id); } break; } case MENU_DELETE: { DestroyStatusDialogFragment.show(fm, status); break; } case MENU_ADD_TO_FILTER: { AddStatusFilterDialogFragment.show(fm, status); break; } case MENU_SET_COLOR: { final Intent intent = new Intent(context, ColorPickerDialogActivity.class); final int color = getUserColor(context, status.user_id, true); if (color != 0) { intent.putExtra(EXTRA_COLOR, color); } intent.putExtra(EXTRA_CLEAR_BUTTON, color != 0); intent.putExtra(EXTRA_ALPHA_SLIDER, false); if (fragment != null) { fragment.startActivityForResult(intent, REQUEST_SET_COLOR); } else if (context instanceof Activity) { ((Activity) context).startActivityForResult(intent, REQUEST_SET_COLOR); } break; } case MENU_CLEAR_NICKNAME: { clearUserNickname(context, status.user_id); break; } case MENU_SET_NICKNAME: { final String nick = getUserNickname(context, status.user_id, true); SetUserNicknameDialogFragment.show(fm, status.user_id, nick); break; } case MENU_TRANSLATE: { final ParcelableCredentials account = ParcelableAccount.getCredentials(context, status.account_id); if (isOfficialCredentials(context, account)) { StatusTranslateDialogFragment.show(fm, status); } else { final Resources resources = context.getResources(); final Locale locale = resources.getConfiguration().locale; try { final String template = "http://translate.google.com/#%s|%s|%s"; final String sourceLang = "auto"; final String targetLang = URLEncoder.encode(locale.getLanguage(), HTTP.UTF_8); final String text = URLEncoder.encode(status.text_unescaped, HTTP.UTF_8); final Uri uri = Uri.parse(String.format(Locale.ROOT, template, sourceLang, targetLang, text)); final Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.addCategory(Intent.CATEGORY_BROWSABLE); context.startActivity(intent); } catch (UnsupportedEncodingException ignore) { } } break; } case MENU_OPEN_WITH_ACCOUNT: { final Intent intent = new Intent(INTENT_ACTION_SELECT_ACCOUNT); intent.setClass(context, AccountSelectorActivity.class); intent.putExtra(EXTRA_SINGLE_SELECTION, true); if (fragment != null) { fragment.startActivityForResult(intent, REQUEST_SELECT_ACCOUNT); } else if (context instanceof Activity) { ((Activity) context).startActivityForResult(intent, REQUEST_SELECT_ACCOUNT); } break; } default: { if (item.getIntent() != null) { try { context.startActivity(item.getIntent()); } catch (final ActivityNotFoundException e) { Crashlytics.logException(e); Log.w(LOGTAG, e); return false; } } break; } } return true; }