List of usage examples for android.content Intent getExtras
public @Nullable Bundle getExtras()
From source file:com.galois.qrstream.MainActivity.java
private Job buildJobFromIntent(Intent intent) throws IllegalArgumentException { String type = intent.getType(); Bundle extras = intent.getExtras(); Log.d(Constants.APP_TAG, "** received type " + type); String name = ""; byte[] bytes = null; Uri dataUrl = (Uri) intent.getExtras().getParcelable(Intent.EXTRA_STREAM); if (dataUrl != null) { name = getNameFromURI(dataUrl);//from w w w . j a v a2 s . c om if (dataUrl.getScheme().equals("content") || dataUrl.getScheme().equals("file")) { try { bytes = readFileUri(dataUrl); } catch (IOException e) { e.printStackTrace(); } } else { Log.d(Constants.APP_TAG, "unsupported url: " + dataUrl); } } else { // fall back to content in extras (mime type dependent) if (type.equals("text/plain")) { String subject = extras.getString(Intent.EXTRA_SUBJECT); String text = extras.getString(Intent.EXTRA_TEXT); if (subject == null) { bytes = text.getBytes(); } else { bytes = encodeSubjectAndText(subject, text); type = Constants.MIME_TYPE_TEXT_NOTE; } } } return new Job(name, bytes, type); }
From source file:MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == PHOTO_RESULT && resultCode == RESULT_OK) { ImageView imageView = (ImageView) findViewById(R.id.imageView); imageView.setImageBitmap(BitmapFactory.decodeFile(mLastPhotoURI.getPath())); if (data != null) { imageView.setImageBitmap((Bitmap) data.getExtras().get("data")); try { imageView.setImageBitmap(MediaStore.Images.Media.getBitmap(getContentResolver(), Uri.parse(data.toUri(Intent.URI_ALLOW_UNSAFE)))); } catch (IOException e) { e.printStackTrace();//from w w w . ja v a2s.co m } } } }
From source file:eu.thecoder4.gpl.pleftdroid.EditEventActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK && data != null) { Bundle extras = data.getExtras(); switch (requestCode) { case ACT_INVITEE: String email = extras.getString(DN_EMAIL); String dname = extras.getString(DN_NAME); if (isUseDispNameSet()) { email = dname + " <" + email + ">"; }/*w ww . j a v a2s. com*/ mEmails.add(email); ((EditText) findViewById(R.id.einvitees)).setText(getInvitees()); break; case ACT_ADDDATE: mDates = data.getParcelableArrayListExtra(PickDateDialogActivity.DTLIST); ((EditText) findViewById(R.id.edatetimes)).setText(getDates()); break; } } }
From source file:de.electricdynamite.pasty.GCMIntentService.java
@SuppressLint("NewApi") @Override/*from w w w. j a va 2s . co m*/ protected void onMessage(Context context, Intent intent) { if (prefs == null) this.prefs = new PastyPreferencesProvider(context); final Bundle extras = intent.getExtras(); if (extras == null) { Log.i(TAG, "onMessage(): Empty intent received"); return; } final String mItemId = extras.getString("itemId"); final String mItemStr = extras.getString("item"); final int mEventId = Integer.parseInt(extras.getString("eventId")); if (mItemId == null || mItemStr == null || mItemId == "" || mItemStr == "") { Log.i(TAG, "onMessage(): Invalid intent received"); return; } if (LOCAL_LOG) Log.v(TAG, "onMessage(): Received message for event: " + mEventId); switch (mEventId) { case EVENT_ITEM_ADDED: final String lastItemId = prefs.getLastItem(); if (mItemId.equals(lastItemId)) return; if (client == null) { client = new PastyClient(prefs.getRESTBaseURL(), true); client.setUsername(prefs.getUsername()); client.setPassword(prefs.getPassword()); } final ClipboardItem mItem = new ClipboardItem(mItemId, mItemStr); final Boolean mPush = prefs.getPush(); final Boolean mCopyToClipboard = prefs.getPushCopyToClipboard(); final Boolean mNotify = prefs.getPushNotify(); if (mPush == true) { if (mCopyToClipboard == true) { if (mItem.getText() != "") { Intent resultIntent = new Intent(this, CopyService.class); resultIntent.putExtra("de.electricdynamite.pasty.itemId", mItem.getId()); resultIntent.putExtra("de.electricdynamite.pasty.item", mItem.getText()); resultIntent.putExtra("de.electricdynamite.pasty.notify", mNotify); startService(resultIntent); resultIntent = null; } } else { if (mNotify == true) { String contentText = String.format(getString(R.string.notification_event_add_text), mItem.getText()); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_pasty) .setContentTitle(getString(R.string.notification_event_add_title)) .setContentText(contentText).setAutoCancel(Boolean.TRUE); // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(this, CopyService.class); resultIntent.putExtra("de.electricdynamite.pasty.itemId", mItem.getId()); resultIntent.putExtra("de.electricdynamite.pasty.item", mItem.getText()); resultIntent.putExtra("de.electricdynamite.pasty.notify", mNotify); PendingIntent resultPendingIntent = PendingIntent.getService(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); // mId allows you to update the notification later on. mNotificationManager.notify(PastySharedStatics.NOTIFICATION_ID, mBuilder.build()); } } JSONArray clipboard = null; try { clipboard = client.getClipboard(); cacheClipboard(clipboard); } catch (PastyException e) { if (LOCAL_LOG) Log.v(TAG, "Could not get clipboard: " + e.getMessage()); } } break; default: Log.i(TAG, "onMessage(): Unsupported event: " + mEventId); break; } /* TODO Make ClipboardFragment react to changes from GCMIntentService */ }
From source file:com.example.main.BandWViewPagerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final GlobalID globalID = ((GlobalID) getApplication()); overridePendingTransition(R.anim.item_in, R.anim.list_out); setContentView(R.layout.activity_view_pager); mViewPager = (HackyViewPager) findViewById(R.id.view_pager); setContentView(mViewPager);/*from w ww .ja va2 s .co m*/ work = false; if (null != savedInstanceState) { final String decode = savedInstanceState.getString("ALL_List"); index = savedInstanceState.getInt("index"); if (log) Log.e(TAG, "null != savedInstanceState ALL_List = " + decode); globalID.start(context); if (globalID.BandWArrays.isEmpty()) { globalID.PD(context, "", "..."); Thread decode_thread = new Thread() { public void run() { getmArrays(decode); Message msg = new Message(); globalID.BandWArrays = ALL_List; mhandler.sendMessage(msg); } }; decode_thread.start(); } } else { Intent intent = getIntent(); Bundle data = intent.getExtras(); index = data.getInt("i"); ALL_List = globalID.BandWArrays; work = true; } samplePagerAdapter = new SamplePagerAdapter(BandWViewPagerActivity.this, IMG_List); mViewPager.setAdapter(samplePagerAdapter); samplePagerAdapter.notifyDataSetChanged(); Thread check = new Thread() { public void run() { while (!work) { try { Thread.sleep(500); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); continue; } } for (int i = 0; i < ALL_List.size(); i++) { BandWEntity entity = ALL_List.get(i); if (!entity.getList_type()) { Message msg = new Message(); msg.what = i; msg.obj = entity; add_img_handler.sendMessage(msg); } } } }; check.start(); }
From source file:eu.codeplumbers.cosi.activities.ExpenseDetailsActivity.java
protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK && requestCode == Constants.REQUEST_RECEIPT_CAPTURE) { photo = (Bitmap) data.getExtras().get("data"); expenseReceipt.setImageBitmap(photo); if (currentReceipt == null) currentReceipt = new Receipt(); }/*from w ww .j av a2s .co m*/ }
From source file:com.example.main.ViewPagerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final GlobalID globalID = (GlobalID) getApplication(); overridePendingTransition(R.anim.item_in, R.anim.list_out); setContentView(R.layout.activity_view_pager); mViewPager = (HackyViewPager) findViewById(R.id.view_pager); setContentView(mViewPager);/*from w w w . j a va 2 s . c om*/ work = false; if (null != savedInstanceState) { final String decode = savedInstanceState.getString("ALL_List"); index = savedInstanceState.getInt("index"); if (log) Log.e(TAG, "null != savedInstanceState ALL_List = " + decode); globalID.start(context); if (globalID.BandWArrays.isEmpty()) { globalID.PD(context, "", "..."); Thread decode_thread = new Thread() { public void run() { getTalkDataArrays(decode); Message msg = new Message(); globalID.TalkList = ALL_List; mhandler.sendMessage(msg); } }; decode_thread.start(); } } else { Intent intent = getIntent(); Bundle data = intent.getExtras(); index = data.getInt("i"); ALL_List = globalID.TalkList; work = true; } samplePagerAdapter = new SamplePagerAdapter(ViewPagerActivity.this, IMG_List); mViewPager.setAdapter(samplePagerAdapter); samplePagerAdapter.notifyDataSetChanged(); Thread check = new Thread() { public void run() { while (!work) { try { Thread.sleep(500); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); continue; } } for (int i = 0; i < ALL_List.size(); i++) { TalkEntity entity = ALL_List.get(i); if (!entity.getIsMsg()) { Message msg = new Message(); msg.what = i; msg.obj = entity; add_img_handler.sendMessage(msg); } } } }; check.start(); }
From source file:com.juanojfp.gcmsample.MainActivity.java
private void getExtrasFromIntent(Intent it) { if (it != null && it.getExtras() != null) { Log.e("Intent GCM ", it.getExtras().toString()); Bundle bundle = it.getExtras();/* w w w .j a v a 2 s . c o m*/ StringBuilder sb = new StringBuilder(); for (String key : bundle.keySet()) { Object value = bundle.get(key); String msg = String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()); sb.append(msg).append("\n"); Log.d(TAG, msg); } if (mDisplay != null) mDisplay.setText(sb.toString()); } else Log.e("Intent GCM ", "NO DATA IN INTENT"); }
From source file:edu.mit.mobile.android.locast.sync.AbsLocastAccountSyncService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Bundle extras = intent.getExtras(); if (extras == null) { extras = new Bundle(); }//from w w w .ja v a2s. c o m extras.putString(EXTRA_SYNC_URI, intent.getData().toString()); final Account account = extras.getParcelable(EXTRA_ACCOUNT); // TODO make this shortcut the Android sync system. ContentResolver.requestSync(account, getAuthority(), extras); return START_NOT_STICKY; }
From source file:com.gmail.srivi.sundaram.locgenie.DisplayPlacesActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.map);//www . j a va 2 s. c o m Intent intent = getIntent(); Location loc = (Location) intent.getExtras().getParcelable(MainActivity.EXTRA_MESSAGE); String radius = intent.getStringExtra(MainActivity.RADIUS); String activityChosen = intent.getStringExtra(MainActivity.ACTIVITY); radiusMain = radius; activity = activityChosen; userIcon = R.drawable.user; if (theMap == null) { SupportMapFragment mapFrag = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); theMap = mapFrag.getMap(); /*theMap = ((MapFragment) getFragmentManager().findFragmentById( R.id.map)).getMap();*/ if (theMap != null) { theMap.setMapType(GoogleMap.MAP_TYPE_HYBRID); placeMarkers = new Marker[MAX_PLACES]; } } double lat = loc.getLatitude(); double lng = loc.getLongitude(); LatLng lastLatLng = new LatLng(lat, lng); theMap.moveCamera(CameraUpdateFactory.newLatLngZoom(lastLatLng, 8)); if (userMarker != null) userMarker.remove(); userMarker = theMap.addMarker( new MarkerOptions().position(lastLatLng).anchor(0.0f, 1.0f).title("You are currently here") .icon(BitmapDescriptorFactory.fromResource(userIcon)).snippet("Your most recent location")); displayPlaces(loc, radius, activityChosen); }