List of usage examples for android.content Intent getExtras
public @Nullable Bundle getExtras()
From source file:com.game.simple.Game3.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (Session.getActiveSession() != null) Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data); ////////////////////image//////////////////// if (resultCode != RESULT_OK) { return;/* w w w . j a v a 2 s .c om*/ } switch (requestCode) { case PICK_FROM_FILE: if (data == null) { Log.e("PICK_FROM_FILE", "NULL"); return; } selectedImage = data.getData(); cropImage(selectedImage); break; case PIC_CROP: if (data == null) { return; } Bundle extras = data.getExtras(); Bitmap thePic = extras.getParcelable("data"); Boolean isSDPresent = android.os.Environment.getExternalStorageState() .equals(android.os.Environment.MEDIA_MOUNTED); if (isSDPresent) { cropedImagePath = Environment.getExternalStorageDirectory().toString() + "/DCIM/avatar.jpeg"; } else { cropedImagePath = "mnt/emmc/avata.jpeg"; } Log.e("---------------path", cropedImagePath); FileOutputStream out = null; try { out = new FileOutputStream(cropedImagePath); thePic.compress(Bitmap.CompressFormat.JPEG, 90, out); } catch (Exception e) { e.printStackTrace(); } finally { try { out.close(); } catch (Throwable ignore) { } } break; case CAMERA_CAPTURE: cameraImage = data.getData(); if (cameraImage == null) { Log.e("CAMERA_CAPTURE", "NULL"); return; } cropImage(cameraImage); break; default: break; } }
From source file:com.frostwire.android.gui.activities.MainActivity.java
private void onDownloadCompleteNotification(Intent intent) { controller.showTransfers(TransferStatus.COMPLETED); TransferManager.instance().clearDownloadsToReview(); try {//from ww w .ja va 2s . c om NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); if (notificationManager != null) { notificationManager.cancel(Constants.NOTIFICATION_DOWNLOAD_TRANSFER_FINISHED); } Bundle extras = intent.getExtras(); if (extras != null) { String downloadCompletePath = extras.getString(Constants.EXTRA_DOWNLOAD_COMPLETE_PATH); if (downloadCompletePath != null) { File file = new File(downloadCompletePath); if (file.isFile()) { UIUtils.openFile(this, file.getAbsoluteFile()); } } } } catch (Throwable e) { LOG.warn("Error handling download complete notification", e); } }
From source file:br.com.rescue_bots_android.bluetooth.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_blue); ActivityHelper.initialize(this); routeController = new RouteController(this); coordinates = new ArrayList<Path>(); trackerController = new TrackerController(this); Intent intent = getIntent(); Bundle b = intent.getExtras(); mDevice = b.getParcelable(Homescreen.DEVICE_EXTRA); mDeviceUUID = UUID.fromString(b.getString(Homescreen.DEVICE_UUID)); mMaxChars = b.getInt(Homescreen.BUFFER_SIZE); Log.d(TAG, "Ready"); mBtnDisconnect = (Button) findViewById(R.id.btnDisconnect); mBtnSend = (Button) findViewById(R.id.btnSend); mBtnClear = (Button) findViewById(R.id.btnClear); mTxtReceive = (TextView) findViewById(R.id.txtReceive); mEditSend = (EditText) findViewById(R.id.editSend); scrollView = (ScrollView) findViewById(R.id.viewScroll); chkScroll = (CheckBox) findViewById(R.id.chkScroll); chkReceiveText = (CheckBox) findViewById(R.id.chkReceiveText); checkBoxJoystickEnable = (CheckBox) findViewById(R.id.checkBoxJoystickEnable); mBtnClearInput = (Button) findViewById(R.id.btnClearInput); mBtnConfig = (Button) findViewById(R.id.buttonConfig2); //imageButtonClaw (Button)findViewById(R.id.imageButtonClaw); editTextAngle = (TextView) findViewById(R.id.editTextAngle); joystickView = (JoystickView) findViewById(R.id.viewJoystick); //Event listener that always returns the variation of the angle in degrees, motion power in percentage and direction of movement ibClaw = (ImageButton) findViewById(R.id.imageButtonClaw); clawControll = new ClawControll(ibClaw); joystickView.setOnJoystickMoveListener(new OnJoystickMoveListener() { @Override//from w ww .j ava 2s .c om public void onValueChanged(int angle, int power, int direction) { // TODO Auto-generated method stub mTxtReceive.append(" " + String.valueOf(angle) + ""); mTxtReceive.append(" " + String.valueOf(power) + "%"); switch (direction) { case JoystickView.FRONT: mTxtReceive.append("FRONT"); sendSerial("a"); break; case JoystickView.FRONT_RIGHT: mTxtReceive.append("FRONT_RIGHT"); sendSerial("c"); break; case JoystickView.RIGHT: mTxtReceive.append("RIGHT"); sendSerial("c"); break; case JoystickView.RIGHT_BOTTOM: mTxtReceive.append("RIGHT_BOTTOM"); sendSerial("f"); break; case JoystickView.BOTTOM: mTxtReceive.append("BOTTOM"); sendSerial("d"); break; case JoystickView.BOTTOM_LEFT: mTxtReceive.append("BOTTOM_LEFT"); sendSerial("e"); break; case JoystickView.LEFT: mTxtReceive.append("LEFT"); sendSerial("b"); break; case JoystickView.LEFT_FRONT: mTxtReceive.append("LEFT_FRONT"); sendSerial("b"); break; default: mTxtReceive.append("CENTER"); sendSerial("g"); } } }, JoystickView.DEFAULT_LOOP_INTERVAL); mTxtReceive.setMovementMethod(new ScrollingMovementMethod()); mBtnDisconnect.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mIsUserInitiatedDisconnect = true; new DisConnectBT().execute(); } }); mBtnSend.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { try { mBTSocket.getOutputStream().write(mEditSend.getText().toString().getBytes()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); mBtnClear.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mEditSend.setText(""); } }); mBtnClearInput.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { //mTxtReceive.setText(""); if (mBtnClearInput.getText().toString().equalsIgnoreCase(LocationManager.GPS_PROVIDER)) { mBtnClearInput.setText(LocationManager.NETWORK_PROVIDER); gps.setProvider(LocationManager.NETWORK_PROVIDER); } else { mBtnClearInput.setText(LocationManager.GPS_PROVIDER); gps.setProvider(LocationManager.GPS_PROVIDER); } } }); mBtnConfig.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent i = new Intent(MainActivity.this, ConfigActivity.class); startActivity(i); } }); ibClaw.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (clawControll != null) { clawControll.changeState(); } } }); checkBoxJoystickEnable.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (checkBoxJoystickEnable.isChecked()) { joystickEnabled = true; joystickView.setEnabled(true); ibClaw.setEnabled(true); } else { joystickEnabled = false; joystickView.setEnabled(false); ibClaw.setEnabled(false); } } }); joystickView.setEnabled(true); ibClaw.setEnabled(true); initGPSListener(); // initialize your android device sensor capabilities mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); image = (ImageView) findViewById(R.id.compassImg); }
From source file:com.appybite.customer.AllowedHotels.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 101 && resultCode == Activity.RESULT_OK) { Bundle extras = data.getExtras(); String qrcode = extras.getString("SCAN_RESULT"); Log.i("Scanner", "QRcode: " + qrcode); String order_type = PrefValue.getString(this, R.string.pref_order_type); if (NetworkUtils.haveInternet(this)) { checkQRCode(order_type, qrcode); } else {//from www . j a v a 2s . co m } } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.openerp.addons.messages.MessageComposeActivty.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_message_compose); scope = new AppScope((MainActivity) MainActivity.context); getActionBar().setHomeButtonEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true); Intent replyIntent = getIntent(); receipients_view = (TagsView) findViewById(R.id.receipients_view); partner_adapter = new ReceipientsTagsCustomAdapter(this, R.layout.message_receipient_item_layout, parters); receipients_view.setAdapter(partner_adapter); /* tags component */ if (replyIntent.hasExtra("send_reply")) { is_reply = true;// w w w. j a va 2 s . co m } else { parters.addAll(getAllPartners()); } receipients_view.setPrefix("To: "); receipients_view.allowDuplicates(false); receipients_view.setTokenListener(this); if (is_reply) { message_id = replyIntent.getExtras().getInt("message_id"); MessageDBHelper msgDb = new MessageDBHelper(this); parent_row = ((List<HashMap<String, Object>>) msgDb.search(msgDb, new String[] { "id = ?" }, new String[] { message_id + "" }).get("records")).get(0); getActionBar().setTitle("?"); EditText edtSubject = (EditText) findViewById(R.id.edtMessageSubject); edtSubject.setText("?: " + parent_row.get("subject").toString()); JSONArray partner_ids = new JSONArray(); try { List<TagsItems> partners = getPartnersOfMessage(message_id + ""); for (TagsItems item : partners) { selectedPartners.put("key_" + item.getId(), item); partner_ids.put(item.getId()); receipients_view.addObject(item); findViewById(R.id.edtMessageBody).requestFocus(); } parent_row.put("partners", partner_ids); } catch (Exception e) { e.printStackTrace(); } } else { getActionBar().setTitle("??"); if (getIntent().getData() != null) { Cursor cursor = managedQuery(getIntent().getData(), null, null, null, null); if (cursor.moveToNext()) { int partner_id = cursor.getInt(cursor.getColumnIndex("data2")); List<TagsItems> partners = getPartnersByIds(Arrays.asList(new Integer[] { partner_id })); for (TagsItems item : partners) { selectedPartners.put("key_" + item.getId(), item); receipients_view.addObject(item); findViewById(R.id.edtMessageSubject).requestFocus(); } } } } lstAttachments = (ListView) findViewById(R.id.lstAttachments); String[] from = new String[] { "name" }; int[] to = new int[] { R.id.txvFileName }; lstAttachmentAdapter = new OEListViewAdapter(MainActivity.context, R.layout.message_attachment_listview_item, attachments, from, to, null); lstAttachments.setAdapter(lstAttachmentAdapter); lstAttachmentAdapter.setItemClickListener(R.id.imgBtnRemoveAttachment, new ControlClickEventListener() { @Override public OEListViewRows controlClicked(int position, OEListViewRows row, View view) { file_uris.remove(position); attachments.remove(position); lstAttachmentAdapter.refresh(attachments); return null; } }); Res_PartnerDBHelper partners = new Res_PartnerDBHelper(this); HashMap<String, Object> data = partners.search(partners); if ((Integer) data.get("total") > 0) { for (HashMap<String, Object> row : (List<HashMap<String, Object>>) data.get("records")) { OEListViewRows newRow = new OEListViewRows(Integer.parseInt(row.get("id").toString()), row); partners_list.add(newRow); } } handleIntentFilter(getIntent()); }
From source file:com.markupartist.sthlmtraveling.RoutesActivity.java
private JourneyQuery getJourneyQueryFromIntent(Intent intent) { JourneyQuery journeyQuery;//w ww . j a v a 2s . com if (intent.hasExtra(EXTRA_JOURNEY_QUERY)) { journeyQuery = intent.getExtras().getParcelable(EXTRA_JOURNEY_QUERY); } else { journeyQuery = getJourneyQueryFromUri(intent.getData()); } return journeyQuery; }
From source file:ch.fixme.status.Widget.java
public void onReceive(Context ctxt, Intent intent) { String action = intent.getAction(); if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(action)) { // Remove widget alarm int widgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); PendingIntent pi = PendingIntent.getService(ctxt, widgetId, getIntent(ctxt, widgetId), 0); AlarmManager am = (AlarmManager) ctxt.getSystemService(Context.ALARM_SERVICE); am.cancel(pi);/*from www. j a va 2 s. com*/ // remove preference SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctxt); Editor edit = prefs.edit(); edit.remove(Main.PREF_API_URL_WIDGET + widgetId); edit.remove(Main.PREF_INIT_WIDGET + widgetId); edit.remove(Main.PREF_LAST_WIDGET + widgetId); edit.remove(Main.PREF_FORCE_WIDGET + widgetId); edit.commit(); // Log.i(Main.TAG, "Remove widget alarm for id=" + widgetId); } else if (intent.hasExtra(WIDGET_IDS) && AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action)) { int[] ids = intent.getExtras().getIntArray(WIDGET_IDS); onUpdate(ctxt, AppWidgetManager.getInstance(ctxt), ids); } else super.onReceive(ctxt, intent); }
From source file:edu.mit.mobile.android.locast.sync.AbsMediaSync.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (ACTION_SYNC_RESOURCES.equals(intent.getAction())) { final Uri data = intent.getData(); if (data == null) { try { enqueueUnpublishedMedia(); } catch (final SyncException e) { Log.e(TAG, "cannot sync request URL", e); }/*w ww .ja v a 2 s. co m*/ } else { enqueueItem(data, intent.getExtras()); } } else { Log.e(TAG, "Media Sync was told to start with an unhandled intent: " + intent); } return START_REDELIVER_INTENT; }
From source file:edu.cens.loci.ui.PlaceListActivity.java
/** * USE CASES:/*from w w w . j a va 2 s . c om*/ * * 1. DEFAULT : * list places and when selected, ACTION_VIEW * * ACTION ... send ACTION_VIEW content://places/pid * SHOW ... * - Suggested places ... add "View GPS Places" * - Registered places ... * - Blocked places ... * - Filter by tag ... * * 2. INSERT_OR_EDIT : * list "create a new place" and "registered" places, when selected, ACTION_EDIT * * ACTION ... send ACTION_EDIT content://places/pid or ACTION_INSERT content://places * - show all suggested/registered/blocked places * SHOW... * - "create a new place" and "registered places" * * 3. PICK : * list places and when selected, return with a uri. * * ACTION ... return a data URL back to the caller * SHOW... * * 4. SEARCH : * TBD * */ @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.place_list); // Resolve the intent final Intent intent = getIntent(); String title = intent.getStringExtra(UI.TITLE_EXTRA_KEY); if (title != null) { setTitle(title); } String action = intent.getAction(); if (Intent.ACTION_VIEW.equals(action)) { mMode = MODE_VIEW; } else if (Intents.UI.ACTION_INSERT.equals(action)) { mMode = MODE_INSERT; } else if (Intents.UI.ACTION_CREATE_OR_ADDTO_FROM_SUGGESTED_PLACE.equals(action)) { mMode = MODE_REGISTER_SUGGESTED; } else if (Intent.ACTION_PICK.equals(action)) { mMode = MODE_PICK; } MyLog.i(LociConfig.D.UI.DEBUG, TAG, String.format("List: mode=%d (%s)", mMode, action)); Bundle extras = intent.getExtras(); if (extras != null) { if (extras.containsKey(Intents.UI.FILTER_STATE_EXTRA_KEY)) mFilterState = extras.getInt(Intents.UI.FILTER_STATE_EXTRA_KEY); if (extras.containsKey(Intents.UI.FILTER_TYPE_EXTRA_KEY)) mFilterType = extras.getInt(Intents.UI.FILTER_TYPE_EXTRA_KEY); if (extras.containsKey(Intents.UI.FILTER_TAG_EXTRA_KEY)) mFilterTag = extras.getString(Intents.UI.FILTER_TAG_EXTRA_KEY); if (extras.containsKey(Intents.UI.LIST_ORDER_EXTRA_KEY)) mListOrder = extras.getInt(Intents.UI.LIST_ORDER_EXTRA_KEY); } mDbUtils = new LociDbUtils(this); }
From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java
private void addMotionChangeListener(CallbackContext callbackContext) { motionChangeCallbacks.add(callbackContext); Activity activity = this.cordova.getActivity(); Intent launchIntent = activity.getIntent(); if (launchIntent.hasExtra("forceReload")) { if (launchIntent.getStringExtra("name") .equalsIgnoreCase(BackgroundGeolocationService.ACTION_ON_MOTION_CHANGE)) { Bundle event = launchIntent.getExtras(); this.onEventMainThread(event); }//from ww w . j a va 2 s.c o m launchIntent.removeExtra("forceReload"); launchIntent.removeExtra("location"); } }