List of usage examples for android.content Intent putExtras
public @NonNull Intent putExtras(@NonNull Bundle extras)
From source file:com.aniruddhc.acemusic.player.NowPlayingQueueActivity.NowPlayingQueueActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { mContext = this; sharedPreferences = getSharedPreferences("com.aniruddhc.acemusic.player", Context.MODE_PRIVATE); //Get the screen's parameters. DisplayMetrics displayMetrics = new DisplayMetrics(); this.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); int screenWidth = displayMetrics.widthPixels; //Set the UI theme. if (sharedPreferences.getString(Common.CURRENT_THEME, "LIGHT_CARDS_THEME").equals("DARK_THEME") || sharedPreferences.getString(Common.CURRENT_THEME, "LIGHT_CARDS_THEME") .equals("DARK_CARDS_THEME")) { setTheme(R.style.AppTheme);//w w w . j ava 2 s . co m } else { setTheme(R.style.AppThemeLight); } super.onCreate(savedInstanceState); if (getOrientation().equals("PORTRAIT")) { //Finish this activity and relaunch the activity that called this one. Intent intent = new Intent(this, (Class<?>) getIntent().getSerializableExtra("CALLING_CLASS")); intent.putExtras(getIntent()); intent.putExtra("NEW_PLAYLIST", false); intent.putExtra("CALLED_FROM_FOOTER", true); intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); finish(); startActivity(intent); return; } else { setContentView(R.layout.activity_now_playing_queue); final Fragment nowPlayingQueueFragment = new NowPlayingQueueFragment(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.add(R.id.now_playing_queue_container, nowPlayingQueueFragment, "nowPlayingQueueFragment"); transaction.commit(); SpannableString s = new SpannableString(getResources().getString(R.string.current_queue)); s.setSpan(new TypefaceSpan(this, "RobotoCondensed-Light"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); // Update the action bar title with the TypefaceSpan instance. ActionBar actionBar = getActionBar(); actionBar.setTitle(s); actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.holo_gray_selector)); } }
From source file:com.Duo.music.player.NowPlayingQueueActivity.NowPlayingQueueActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { mContext = this; sharedPreferences = getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE); //Get the screen's parameters. DisplayMetrics displayMetrics = new DisplayMetrics(); this.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); int screenWidth = displayMetrics.widthPixels; //Set the UI theme. if (sharedPreferences.getString(Common.CURRENT_THEME, "LIGHT_CARDS_THEME").equals("DARK_THEME") || sharedPreferences.getString(Common.CURRENT_THEME, "LIGHT_CARDS_THEME") .equals("DARK_CARDS_THEME")) { setTheme(R.style.AppTheme);/*w w w.j a v a 2 s.c o m*/ } else { setTheme(R.style.AppThemeLight); } super.onCreate(savedInstanceState); if (getOrientation().equals("PORTRAIT")) { //Finish this activity and relaunch the activity that called this one. Intent intent = new Intent(this, (Class<?>) getIntent().getSerializableExtra("CALLING_CLASS")); intent.putExtras(getIntent()); intent.putExtra("NEW_PLAYLIST", false); intent.putExtra("CALLED_FROM_FOOTER", true); intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); finish(); startActivity(intent); return; } else { setContentView(R.layout.activity_now_playing_queue); final Fragment nowPlayingQueueFragment = new NowPlayingQueueFragment(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.add(R.id.now_playing_queue_container, nowPlayingQueueFragment, "nowPlayingQueueFragment"); transaction.commit(); SpannableString s = new SpannableString(getResources().getString(R.string.current_queue)); s.setSpan(new TypefaceSpan(this, "RobotoCondensed-Light"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); // Update the action bar title with the TypefaceSpan instance. ActionBar actionBar = getActionBar(); actionBar.setTitle(s); actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.holo_gray_selector)); } }
From source file:com.example.android.sunshine.app.ui.ForecastFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { List<String> weekForecast = new ArrayList<String>(); // Now that we have some dummy forecast data, create an ArrayAdapter. // The ArrayAdapter will take data from a source (like our dummy forecast) and // use it to populate the ListView it's attached to. mForecastAdapter = new ArrayAdapter<String>(getActivity(), // The current context (this activity) R.layout.list_item_forecast, // The name of the layout ID. R.id.list_item_forecast_textview, // The ID of the textview to populate. weekForecast);/*from w ww. j av a2 s .c o m*/ View rootView = inflater.inflate(R.layout.fragment_main, container, false); // Get a reference to the ListView, and attach this adapter to it. ListView listView = (ListView) rootView.findViewById(R.id.listview_forecast); listView.setAdapter(mForecastAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) { String forecast = mForecastAdapter.getItem(position); Bundle b = new Bundle(); b.putString("forecast", forecast); Intent intentDetail = new Intent(getActivity(), DetailActivity.class); intentDetail.putExtras(b); startActivity(intentDetail); } }); return rootView; }
From source file:com.wenwen.chatuidemo.activity.AddContactActivity.java
/** * contact/*from w ww . j a v a2 s .com*/ * * @param view */ public void addContact(View view) { if (DemoApplication.getInstance().getUserName().equals(nameText.getText().toString())) { startActivity(new Intent(this, AlertDialog.class).putExtra("msg", "?")); return; } final ProgressDialog pd = new ProgressDialog(AddContactActivity.this); pd.setMessage("..."); RequestParams params = new RequestParams(); DebugLog.i(TAG, "uid" + DemoApplication.getInstance().getUserUid()); params.put("fromuid", DemoApplication.getInstance().getUserUid()); params.put("touid", myUser.getAccount_id()); params.put("flag", "1"); HttpClientRequest.post(Urls.FRIENDSSET, params, 3000, new AsyncHttpResponseHandler() { @Override public void onStart() { // TODO Auto-generated method stub super.onStart(); pd.show(); } @Override public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { // TODO Auto-generated method stub try { String res = new String(arg2); DebugLog.i(TAG, "" + res); JSONObject result = new JSONObject(res); switch (Integer.valueOf(result.getString("ret"))) { case 0: Toast.makeText(AddContactActivity.this, "", Toast.LENGTH_SHORT).show(); break; case 1: Toast.makeText(AddContactActivity.this, "?", Toast.LENGTH_SHORT).show(); Bundle bundle = new Bundle(); bundle.putSerializable("myuser", myUser); Intent data = new Intent(); data.putExtras(bundle); setResult(Activity.RESULT_OK, data); // ??? finish(); break; case -2: Toast.makeText(AddContactActivity.this, "??", Toast.LENGTH_SHORT).show(); break; default: break; } } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } @Override public void onFinish() { // TODO Auto-generated method stub super.onFinish(); pd.dismiss(); } @Override public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { // TODO Auto-generated method stub } }); }
From source file:com.amytech.android.library.views.imagechooser.api.MediaChooserManager.java
private void chooseMedia() throws Exception { checkDirectory();//from w w w.ja v a 2 s . c o m try { Intent intent = new Intent(Intent.ACTION_PICK); if (extras != null) { intent.putExtras(extras); } intent.setType("video/*, image/*"); startActivity(intent); } catch (ActivityNotFoundException e) { throw new Exception("Activity not found"); } }
From source file:com.arquitetaweb.restaurantes.fragment.CardapioFragment.java
private void carregarDadosJson(final View view) { handler = new Handler(); progressDialog = new ProgressDialog(contexto); progressDialog.setCancelable(false); progressDialog.setMessage("atualizando mapa das mesas..."); progressDialog.show();/* w w w . j a v a 2s .c o m*/ Thread thread = new Thread() { public void run() { if (Utils.isConnected(contexto)) { String url = Utils.getUrlServico(contexto) + "/Api/SituacaoMesas"; JSONParser jParser = new JSONParser(); json = jParser.getJSONFromUrl(url); contexto.runOnUiThread(new Runnable() { public void run() { ArrayList<HashMap<String, String>> mesasLista = new ArrayList<HashMap<String, String>>(); for (int i = 0; i < json.length(); i++) { try { JSONObject c = json.getJSONObject(i); HashMap<String, String> map = new HashMap<String, String>(); map.put(KEY_ID, c.getString(KEY_ID)); map.put(KEY_NUMEROMESA, c.getString(KEY_NUMEROMESA)); map.put(KEY_CODIGOEXTERNO, c.getString(KEY_CODIGOEXTERNO)); map.put(KEY_SITUACAO, c.getString(KEY_SITUACAO)); mesasLista.add(map); } catch (JSONException e) { e.printStackTrace(); } } mesas = (GridView) view.findViewById(R.id.list); adapter = new MesaAdapter(contexto, mesasLista); mesas.setAdapter(adapter); // Click event for single list row mesas.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { TextView idItem = (TextView) view.findViewById(R.id.idItem); Bundle bun = new Bundle(); bun.putString("id", (String) idItem.getText()); abrirDetalhes(view, bun); } private void abrirDetalhes(View view, Bundle bun) { Intent intent = new Intent(view.getContext(), DetailsActivity.class); intent.putExtras(bun); startActivityForResult(intent, 100); } }); progressDialog.dismiss(); } }); } else { contexto.runOnUiThread(new Runnable() { public void run() { progressDialog.dismiss(); new Alerta(contexto, "", "No Foi Localizado o Servidor!" + "\nCausas:" + "\nConexo OK?" + "\nServidor correto?"); // Toast.makeText(contexto, "No Foi Localizado o Servidor!", // Toast.LENGTH_LONG).show(); //Intent intent = new Intent("settings://sandbox"); //startActivity(intent); } }); } } }; thread.start(); }
From source file:eu.thecoder4.gpl.pleftdroid.EditEventActivity.java
/** Called when the activity is first created. */ @Override/*from w ww . ja v a 2s . c om*/ public void onCreate(Bundle savedInstanceState) { if (AppPreferences.INSTANCE.getUsePleftTheme()) { setTheme(R.style.Theme_Pleft); } super.onCreate(savedInstanceState); // Initialiazations mTHISEVENT = this; mDates = new ArrayList<PDate>(); mEmails = new ArrayList<String>(); // The View setContentView(R.layout.edit_event); // Add Invitee Button ((Button) findViewById(R.id.addinvitee)).setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent iai = new Intent(mTHISEVENT, SelectContactsActivity.class); startActivityForResult(iai, ACT_INVITEE); } }); // Add Date Button ((Button) findViewById(R.id.adddate)).setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent iad = new Intent(mTHISEVENT, PickDateDialogActivity.class); // This would not work: you need a Parcelable //iad.putExtra(PickDateDialogActivity.DTLIST, mDates); iad.putParcelableArrayListExtra(PickDateDialogActivity.DTLIST, mDates); startActivityForResult(iad, ACT_ADDDATE); } }); // Send Invitations Button ((Button) findViewById(R.id.sendinvite)).setOnClickListener(new OnClickListener() { private int SC; @SuppressWarnings("static-access") public void onClick(View v) { String desc = ((EditText) findViewById(R.id.edescription)).getText().toString(); String invitees = ((EditText) findViewById(R.id.einvitees)).getText().toString(); String dates = getPleftDates();//"2011-06-23T21:00:00\n2011-06-24T21:00:00\n2011-06-25T21:00:00"; boolean proposemore = ((CheckBox) findViewById(R.id.mayproposedate)).isChecked(); if (desc == null || desc.length() == 0 || invitees == null || invitees.length() == 0 || dates == null || dates.length() == 0) { Toast.makeText(EditEventActivity.this, R.string.event_completeform, Toast.LENGTH_LONG).show(); } else { // Get Preferences //Toast.makeText(EditEventActivity.this, "invitees: "+invitees+"\nDesc="+desc+"\npserver="+pserver, Toast.LENGTH_LONG).show(); SC = PleftBroker.INSTANCE.createAppointment(desc, invitees, dates, AppPreferences.INSTANCE.getPleftServer().trim(), //pserver, AppPreferences.INSTANCE.getName().trim(), //uname, AppPreferences.INSTANCE.getEmail().trim(), //uemail, proposemore); if (SC == HttpStatus.SC_OK) { PleftDroidDbAdapter mDbAdapter = new PleftDroidDbAdapter(EditEventActivity.this); mDbAdapter.open(); mDbAdapter.createAppointmentAsInvitor(0, desc, AppPreferences.INSTANCE.getPleftServer().trim(), AppPreferences.INSTANCE.getEmail().trim()); mDbAdapter.close(); } Bundle bundle = new Bundle(); bundle.putInt(PleftDroidActivity.SC_CREATE, SC); Intent i = new Intent(); i.putExtras(bundle); setResult(RESULT_OK, i); // Close activity finish(); } } }); }
From source file:app.android.kopper.selectmaparea.MapActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { try {/* w ww.java 2 s.c o m*/ super.onCreate(savedInstanceState); setContentView(R.layout.activity_map); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); final GoogleMap map = mapFragment.getMap(); //todo: map is null when no internet connection ?? if (map != null) { map.getUiSettings().setCompassEnabled(false); map.getUiSettings().setZoomControlsEnabled(true); map.getUiSettings().setIndoorLevelPickerEnabled(false); map.getUiSettings().setRotateGesturesEnabled(false); map.setOnMapLongClickListener(new GoogleMap.OnMapLongClickListener() { @Override public void onMapLongClick(LatLng latLng) { createMarker(latLng, map); } }); findViewById(R.id.done_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { LinkedList<LatLng> positions = getPositions(); if (positions.size() != 2) Toast.makeText(getApplicationContext(), getString(R.string.error_two_points), Toast.LENGTH_SHORT).show(); else { Intent data = getOrCreateIntent(); data.putExtra(SELECTED_POSITIONS, positions); Serializable nextPage = data .getSerializableExtra(MapActivity.class.getCanonicalName() + "-next"); if (nextPage != null) { try { Intent ii = new Intent(getApplicationContext(), (Class<?>) nextPage); ii.putExtras(data); startActivityForResult(ii, WIZARD_RESULT_CODE); } catch (Exception e) { LogUtil.e(e); } } else { setResult(RESULT_OK, data); finish(); } } } }); LinkedList<LatLng> positions = (LinkedList<LatLng>) getLastCustomNonConfigurationInstance(); if (positions != null) { for (int a = 0; a < positions.size(); a++) { createMarker(positions.get(a), map); } } else { Intent intent = getOrCreateIntent(); Bundle extras = intent.getExtras(); List<LatLng> selectedPoints = (List<LatLng>) extras.get(SELECTED_POSITIONS); if (selectedPoints != null) for (LatLng pos : selectedPoints) createMarker(pos, map); map.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() { @Override public void onCameraChange(CameraPosition arg0) { map.setOnCameraChangeListener(null); if (markers.size() == 2) map.moveCamera(CameraUpdateFactory.newLatLngBounds(new LatLngBounds( markers.get(0).getPosition(), markers.get(1).getPosition()), 40)); if (markers.size() == 1) map.moveCamera(CameraUpdateFactory.newLatLngZoom(markers.get(0).getPosition(), 10)); } }); } } else { //no map ((TextView) findViewById(R.id.message)).setText(getString(R.string.error_map_load)); } } catch (Exception e) { LogUtil.e(e); } }
From source file:com.andrewchelladurai.simplebible.ChapterFragment.java
private void bookmarkButtonClicked() { Collection<VerseItem> items = VerseList.getSelectedItems(); if (items.isEmpty()) { Log.e(TAG, "bookmarkButtonClicked: returning - No Selected Entries :\n" + getString(R.string.how_am_i_here)); return;//from ww w . j ava 2s .c o m } String reference = Utilities.prepareBookmarkReferenceFromVerseList(items); if (reference.isEmpty()) { Log.e(TAG, "bookmarkButtonClicked: returning - reference is empty"); return; } String returnValue = mPresenter.bookmarkButtonClicked(reference); Bundle args = new Bundle(); args.putString(BookmarkActivityOperations.ARG_REFERENCE, reference); switch (returnValue) { case BookmarkActivityOperations.VIEW: args.putString(BookmarkActivityOperations.ARG_MODE, BookmarkActivityOperations.VIEW); break; case BookmarkActivityOperations.CREATE: default: args.putString(BookmarkActivityOperations.ARG_MODE, BookmarkActivityOperations.CREATE); Log.w(TAG, "bookmarkButtonClicked: " + getString(R.string.how_am_i_here)); Log.w(TAG, "bookmarkButtonClicked: setting ARG_MODE = CREATE"); } Intent intent = new Intent(getContext(), BookmarkActivity.class); intent.putExtras(args); startActivity(intent); }
From source file:activities.SpecialityActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.service_list); lv = (ListView) findViewById(R.id.list_view); inputSearch = (EditText) findViewById(R.id.inputSearch); //adapter = new ArrayAdapter<String>(activity, R.layout.service_list_item, R.id.service_name,services); adapter = new SpecialityAdapter(this, R.layout.service_list_item, Arrays.asList(services)); lv.setAdapter(adapter);//from w w w . j ava 2s. c o m inputSearch.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); } @Override public void afterTextChanged(Editable s) { } }); ((Button) findViewById(R.id.button)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < specialities.size(); i++) { // Log.e("key", specialities+""); specialities_new = specialities; Log.e("key", specialities_new + ""); } // for(String speciality : specialities) { // //System.out.println(speciality); // Log.e("key", speciality); // key = speciality; // Log.e("keys", key+" "); // } // Intent returnIntent = new Intent(); // Bundle bundle = new Bundle(); // bundle.putSerializable("result", specialities_new); // returnIntent.putExtra(bundle); // setResult(1, returnIntent); Intent intent = new Intent(); Bundle bundle1 = new Bundle(); bundle1.putSerializable("passwords", specialities_new); intent.putExtras(bundle1); setResult(1, intent); finish(); } }); }