List of usage examples for android.content Intent putExtras
public @NonNull Intent putExtras(@NonNull Bundle extras)
From source file:anomalyDetector.activities.MainFeaturesActivity.java
public void startService(View view) { Intent intent = new Intent(ColectFeaturesService.COLECT_FEATURE_SERVICE); Bundle bundle = new Bundle(); bundle.putStringArrayList(SELECTED_FEATURES, selectedFeatures); intent.putExtras(bundle); startService(intent);//ww w . j a v a2s.com isServiceRunning = true; drawerItemClickListener.setServiceRunning(true); startServiceButton = (Button) findViewById(R.id.startServiceButton); startServiceButton.setEnabled(false); stopServiceButton = (Button) findViewById(R.id.stopServiceButton); stopServiceButton.setEnabled(true); }
From source file:com.abcvoipsip.ui.messages.ConversationsListFragment.java
public void viewDetails(int position, String number, String fromFull) { Bundle b = MessageFragment.getArguments(number, fromFull); if (mDualPane) { // If we are not currently showing a fragment for the new // position, we need to create and install a new one. MessageFragment df = new MessageFragment(); df.setArguments(b);/*w w w . j a va2s . c o m*/ // Execute a transaction, replacing any existing fragment // with this one inside the frame. FragmentTransaction ft = getFragmentManager().beginTransaction(); ft.replace(R.id.details, df, null); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.commit(); getListView().setItemChecked(position, true); } else { Intent it = new Intent(getActivity(), MessageActivity.class); it.putExtras(b); startActivity(it); } }
From source file:Main.java
public static Intent mapToIntent(Context context, Class<?> clazz, Map<String, Object> map) { Intent intent = new Intent(context, clazz); Bundle bundle = new Bundle(); if (map != null && map.size() > 0) { for (String key : map.keySet()) { if (map.get(key) instanceof String) { bundle.putString(key, (String) map.get(key)); } else if (map.get(key) instanceof Integer) { bundle.putInt(key, (Integer) map.get(key)); } else if (map.get(key) instanceof Boolean) { bundle.putBoolean(key, (Boolean) map.get(key)); } else if (map.get(key) instanceof Double) { bundle.putDouble(key, (Double) map.get(key)); } else if (map.get(key) instanceof Long) { bundle.putLong(key, (Long) map.get(key)); } else if (map.get(key) instanceof Float) { bundle.putFloat(key, (Float) map.get(key)); } else if (map.get(key) instanceof Double) { bundle.putDouble(key, (Double) map.get(key)); } else if (map.get(key) instanceof Serializable) { bundle.putSerializable(key, (Serializable) map.get(key)); } else if (map.get(key) instanceof Parcelable) { bundle.putParcelable(key, (Parcelable) map.get(key)); }/*from w w w. j a va2 s . c om*/ } } return intent.putExtras(bundle); }
From source file:ca.ualberta.cs.shoven_habittracker.AllHabitsActivity.java
@Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { Intent intent = new Intent(); intent.setClass(this, HabitHomepageActivity.class); Bundle bundle = new Bundle(); bundle.putInt("position", position); bundle.putString("activity", "AllHabitsActivity"); intent.putExtras(bundle); startActivity(intent);//from ww w . j a v a 2 s . co m }
From source file:com.amytech.android.library.views.imagechooser.api.ImageChooserManager.java
private void choosePicture() throws Exception { checkDirectory();/*from w w w .j a v a 2 s .c o m*/ try { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); if (extras != null) { intent.putExtras(extras); } startActivity(intent); } catch (ActivityNotFoundException e) { throw new Exception("Activity not found"); } }
From source file:com.parse.ParsePushBroadcastReceiver.java
/** * Called when the push notification is received. By default, a broadcast intent will be sent if * an "action" is present in the data and a notification will be show if "alert" and "title" are * present in the data.//w w w . j av a2 s. com * * @param context * The {@code Context} in which the receiver is running. * @param intent * An {@code Intent} containing the channel and data of the current push notification. */ protected void onPushReceive(Context context, Intent intent) { String pushDataStr = intent.getStringExtra(KEY_PUSH_DATA); if (pushDataStr == null) { PLog.e(TAG, "Can not get push data from intent."); return; } PLog.v(TAG, "Received push data: " + pushDataStr); JSONObject pushData = null; try { pushData = new JSONObject(pushDataStr); } catch (JSONException e) { PLog.e(TAG, "Unexpected JSONException when receiving push data: ", e); } // If the push data includes an action string, that broadcast intent is fired. String action = null; if (pushData != null) { action = pushData.optString("action", null); } if (action != null) { Bundle extras = intent.getExtras(); Intent broadcastIntent = new Intent(); broadcastIntent.putExtras(extras); broadcastIntent.setAction(action); broadcastIntent.setPackage(context.getPackageName()); context.sendBroadcast(broadcastIntent); } Notification notification = getNotification(context, intent); if (notification != null) { ParseNotificationManager.getInstance().showNotification(context, notification); } }
From source file:com.hua.goddess.activites.RegisterActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_register); pd = new ProgressDialog(RegisterActivity.this); // DeviceUuidFactory uuid = new DeviceUuidFactory(this); // uid = uuid.getDeviceUuid().toString(); emailEditText = (EditText) findViewById(R.id.email); emailEditText.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);// ?? userNameEditText = (EditText) findViewById(R.id.username); passwordEditText = (EditText) findViewById(R.id.password); confirmPwdEditText = (EditText) findViewById(R.id.confirm_password); rg = (RadioGroup) findViewById(R.id.sex); b1 = (RadioButton) findViewById(R.id.male); b2 = (RadioButton) findViewById(R.id.female); wh = new WsRequestHelper(new WsRequestHelper.InterfaceCallBack() { @Override//w ww .j av a 2 s .c o m public void RequestCallBack(Object result) { // TODO Auto-generated method stub pd.dismiss(); // Toast.makeText(RegisterActivity.this, result.toString(), // Toast.LENGTH_SHORT).show(); if (result.toString().equals("?")) { Intent intent = new Intent(RegisterActivity.this, LoginActivity.class); Bundle bundle = new Bundle(); bundle.putString("username", userNameEditText.getText().toString().trim()); intent.putExtras(bundle); setResult(100, intent); finish(); } } }); rg.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { // TODO Auto-generated method stub if (checkedId == b1.getId()) { sex = "1"; Toast.makeText(RegisterActivity.this, "", Toast.LENGTH_LONG).show(); } if (checkedId == b2.getId()) { sex = "2"; Toast.makeText(RegisterActivity.this, "", Toast.LENGTH_LONG).show(); } } }); }
From source file:com.example.gps_project.Places.java
@Override public void onItemClick(AdapterView<?> arg0, View v, final int position, long arg3) { try {/*w ww . ja v a 2s . co m*/ new AlertDialog.Builder(this).setTitle(R.string.check_in_title) .setMessage(String.format(getString(R.string.check_in_at), jsonArray.getJSONObject(position).getString("name"))) .setPositiveButton(R.string.checkin, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String placeID = ""; final JSONObject coordinate = new JSONObject(); try { placeID = jsonArray.getJSONObject(position).getString("id"); coordinate.put("latitude", jsonArray.getJSONObject(position) .getJSONObject("location").getString("lat")); coordinate.put("longitude", jsonArray.getJSONObject(position) .getJSONObject("location").getString("lon")); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } params.putString("place", placeID); params.putString("accesstoken", Session.getActiveSession().getAccessToken()); params.putString("coordinates", coordinate.toString()); Intent myIntent = new Intent(getApplicationContext(), CheckinPage.class); myIntent.putExtras(params); startActivity(myIntent); } }).setNegativeButton(R.string.cancel, null).show(); } catch (JSONException e) { showToast("Error: " + e.getMessage()); } //} }
From source file:com.parse.ParseAnalyticsTest.java
@Test public void testGetPushHashFromIntentWrongPushHashIntent() throws Exception { Intent intent = new Intent(); Bundle bundle = new Bundle(); bundle.putString(ParsePushBroadcastReceiver.KEY_PUSH_DATA, "error_data"); intent.putExtras(bundle); String pushHash = ParseAnalytics.getPushHashFromIntent(intent); assertEquals(null, pushHash);/*from ww w. j a v a2 s.c om*/ }
From source file:com.example.jony.myapp.reader_APP.adapter.ReadingItemAdapter.java
@Override public void onBindViewHolder(final ViewHolder holder, int position) { final BookBean bookBean = mList.get(position); holder.title.setText(bookBean.getTitle()); holder.info.setText(bookBean.getInfo()); if (Settings.noPicMode && HttpUtil.isWIFI == false) { holder.image.setImageURI(null);/*from www . jav a2 s . co m*/ } else { holder.image.setImageURI(Uri.parse(bookBean.getImage())); } holder.parentView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(mContext, ReadingDetailsActivity.class); Bundle bundle = new Bundle(); bundle.putSerializable(mContext.getString(R.string.reader_id_book), bookBean); intent.putExtras(bundle); mContext.startActivity(intent); } }); // set ebook if (Utils.hasString(bookBean.getEbook_url())) { holder.ebook.setVisibility(View.VISIBLE); } else { holder.ebook.setVisibility(View.GONE); } if (isCollection) { holder.collect_cb.setVisibility(View.GONE); holder.text.setText(R.string.reader_text_remove); holder.text.setTextColor(ContextCompat.getColor(mContext, R.color.colorPrimary)); holder.text.setTextSize(18); holder.text.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Snackbar.make(holder.parentView, R.string.reader_notify_remove_from_collection, Snackbar.LENGTH_SHORT) .setAction(mContext.getString(R.string.reader_text_ok), new View.OnClickListener() { @Override public void onClick(View v) { /*if (mItems.contains(bookBean) == false) { return; } mCache.execSQL(ReadingTable.updateCollectionFlag(bookBean.getTitle(), 0)); mCache.execSQL(ReadingTable.deleteCollectionFlag(bookBean.getTitle())); mItems.remove(position); notifyDataSetChanged();*/ } }).show(); } }); return; } holder.collect_cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { /*bookBean.setIs_collected(isChecked ? 1 : 0); mCache.execSQL(ReadingTable.updateCollectionFlag(bookBean.getTitle(), isChecked ? 1 : 0)); if (isChecked) { mCache.addToCollection(bookBean); } else { mCache.execSQL(ReadingTable.deleteCollectionFlag(bookBean.getTitle())); }*/ } }); holder.collect_cb.setChecked(bookBean.getIs_collected() == 1 ? true : false); }