List of usage examples for android.content Intent getData
public @Nullable Uri getData()
From source file:androidVNC.VncCanvasActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); database = new VncDatabase(this); connection = new ConnectionBean(); Intent i = getIntent(); Uri data = i.getData(); if ((data != null) && (data.getScheme().equals("vnc"))) { String host = data.getHost(); // This should not happen according to Uri contract, but bug introduced in Froyo (2.2) // has made this parsing of host necessary int index = host.indexOf(':'); int port; if (index != -1) { try { port = Integer.parseInt(host.substring(index + 1)); } catch (NumberFormatException nfe) { port = 0;// w ww . ja v a2 s . c o m } host = host.substring(0, index); } else { port = data.getPort(); } if (host.equals(VncConstants.CONNECTION)) { if (connection.Gen_read(database.getReadableDatabase(), port)) { MostRecentBean bean = androidVNC.getMostRecent(database.getReadableDatabase()); if (bean != null) { bean.setConnectionId(connection.get_Id()); bean.Gen_update(database.getWritableDatabase()); } } } else { connection.setAddress(host); connection.setNickname(connection.getAddress()); connection.setPort(port); List<String> path = data.getPathSegments(); if (path.size() >= 1) { connection.setColorModel(path.get(0)); } if (path.size() >= 2) { connection.setPassword(path.get(1)); } connection.save(database.getWritableDatabase()); } } else { Bundle extras = i.getExtras(); if (extras != null) { connection.Gen_populate((ContentValues) extras.getParcelable(VncConstants.CONNECTION)); } if (connection.getPort() == 0) connection.setPort(5900); // Parse a HOST:PORT entry String host = connection.getAddress(); if (host.indexOf(':') > -1) { String p = host.substring(host.indexOf(':') + 1); try { connection.setPort(Integer.parseInt(p)); } catch (Exception e) { } connection.setAddress(host.substring(0, host.indexOf(':'))); } } try { setContentView(fi.aalto.openoranges.project1.mcc.R.layout.canvas); vncCanvas = (VncCanvas) findViewById(fi.aalto.openoranges.project1.mcc.R.id.vnc_canvas); zoomer = (ZoomControls) findViewById(R.id.zoomer); } catch (Exception e) { e.printStackTrace(); } vncCanvas.initializeVncCanvas(connection, new Runnable() { public void run() { setModes(); } }); vncCanvas.setOnGenericMotionListener(this); zoomer.hide(); zoomer.setOnZoomInClickListener(new View.OnClickListener() { /* * (non-Javadoc) * * @see android.view.View.OnClickListener#onClick(android.view.View) */ @Override public void onClick(View v) { showZoomer(true); vncCanvas.scaling.zoomIn(VncCanvasActivity.this); } }); zoomer.setOnZoomOutClickListener(new View.OnClickListener() { /* * (non-Javadoc) * * @see android.view.View.OnClickListener#onClick(android.view.View) */ @Override public void onClick(View v) { showZoomer(true); vncCanvas.scaling.zoomOut(VncCanvasActivity.this); } }); zoomer.setOnZoomKeyboardClickListener(new View.OnClickListener() { /* * (non-Javadoc) * * @see android.view.View.OnClickListener#onClick(android.view.View) */ @Override public void onClick(View v) { InputMethodManager inputMgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); inputMgr.toggleSoftInput(0, 0); } }); panner = new Panner(this, vncCanvas.handler); inputHandler = getInputHandlerById(fi.aalto.openoranges.project1.mcc.R.id.itemInputFitToScreen); mToken = getIntent().getStringExtra("token"); mId = getIntent().getStringExtra("id"); mName = getIntent().getStringExtra("name"); //listener for the back-button registerClickCallback(); //Notification in status bar NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(VncCanvasActivity.this) .setSmallIcon(R.drawable.icon_white).setContentTitle(mName + " running") .setContentText("Click to open the application screen"); // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(VncCanvasActivity.this, VncCanvasActivity.class); resultIntent.setAction(Long.toString(System.currentTimeMillis())); mBuilder.setContentIntent(PendingIntent.getActivity(VncCanvasActivity.this, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT)); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); // mNotifyID allows you to update the notification later on. mNotificationManager.notify(mNotifyId, mBuilder.build()); startService(); }
From source file:in.shick.diode.threads.ThreadsListActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); switch (requestCode) { //add constant to specify search case Constants.ACTIVITY_PICK_SUBREDDIT: if (resultCode == Activity.RESULT_OK) { Matcher redditContextMatcher = REDDIT_PATH_PATTERN.matcher(intent.getData().getPath()); if (redditContextMatcher.matches()) { mObjectStates.mCurrentDownloadThreadsTask = new MyDownloadThreadsTask( redditContextMatcher.group(1)); mObjectStates.mCurrentDownloadThreadsTask.execute(); }// w ww. j a v a 2 s . com } break; case Constants.ACTIVITY_SEARCH_REDDIT: if (resultCode == Activity.RESULT_OK) { //changed it so each piece of data is passed separately as extras in the intent //rather than having to use regex to split apart a string //could probably do away with the "subreddit" field since we're //using a modified constructor anyways mObjectStates.mCurrentDownloadThreadsTask = new MyDownloadThreadsTask( intent.getExtras().getString("searchurl"), intent.getExtras().getString("query"), intent.getExtras().getString("sort")); mObjectStates.mCurrentDownloadThreadsTask.execute(); } break; default: break; } }
From source file:com.tsp.clipsy.audio.RingdroidEditActivity.java
/** Called with the activity is first created. */ @Override//from w w w .ja va 2 s .com public void onCreate(Bundle icicle) { super.onCreate(icicle); mRecordingFilename = null; mRecordingUri = null; mPlayer = null; mIsPlaying = false; Intent intent = getIntent(); if (intent.getBooleanExtra("privacy", false)) { finish(); return; } // If the Ringdroid media select activity was launched via a // GET_CONTENT intent, then we shouldn't display a "saved" // message when the user saves, we should just return whatever // they create. mWasGetContentIntent = intent.getBooleanExtra("was_get_content_intent", false); mFilename = intent.getData().toString(); mSoundFile = null; mKeyDown = false; if (mFilename.equals("record")) { try { Intent recordIntent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION); startActivityForResult(recordIntent, REQUEST_CODE_RECORD); } catch (Exception e) { showFinalAlert(e, R.string.record_error); } } mHandler = new Handler(); loadGui(); mHandler.postDelayed(mTimerRunnable, 100); if (!mFilename.equals("record")) { loadFromFile(); } }
From source file:com.adamas.client.android.MainActivity.java
public void onActivityResult(int requestCode, int resultCode, Intent intent) { IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent); if (scanResult != null) { // handle scan result String content = scanResult.getContents(); processQrCodeText(content);/*from ww w .j a v a2 s . c om*/ } else { if (resultCode == Activity.RESULT_OK) { if (requestCode == VPNSERVICE_PERMISSION) { DefaultSettings.USERNAME = _selectedAdamasConnector.getUsername(); DefaultSettings.PASSWORD = _selectedAdamasConnector.getPassword(); connectOpenvpn(_selectedAdamasConnector); } else if (IMPORT_CONNECTOR_REQUEST_CODE == requestCode) { } else if (MANUALLY_ADD_CONNECTOR_REQUEST_CODE == requestCode) { } else if (MANUALLY_EDIT_CONNECTOR_REQUEST_CODE == requestCode) { } else if (IMPORT_FROM_TEXT_REQUEST_CODE == requestCode) { } else if (IMPORT_FROM_FILE_REQUEST_CODE == requestCode) { Uri selectedimg = intent.getData(); try { Result result = decode(selectedimg); String content = result.getText(); processQrCodeText(content); } catch (Exception e) { e.printStackTrace(); } } else { } } else { if (requestCode == VPNSERVICE_PERMISSION) { _runProcessConnectDisconnectKey = false; ((Switch) findViewById(R.id.switchForStartStopConnector)).setChecked(false); } } } //TODO - refresh vpnlist if (_connectorfragment != null) { _connectorfragment.processRefreshKey(); } }
From source file:illab.nabal.NabalSimpleDemoActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // if request code is sent from here and the result is ok if (requestCode == REQ_CODE_FETCH_BITMAP_FROM_GALLERY && resultCode == RESULT_OK) { Uri imgUri = data.getData(); // if user has selected a photo from Gallery if (imgUri.toString().startsWith("content://media") == true) { // imgUri : content://media/external/images/media/13570 String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(imgUri, filePathColumn, null, null, null); if (cursor.moveToFirst() == true) { int columnIndex = cursor.getColumnIndex(filePathColumn[0]); // go post this photo with description mTmpImgFilePath = cursor.getString(columnIndex); postPhoto(mTmpImgFilePath, mEditText1.getText().toString()); // uncomment and use Bitmap object to handle the selected bitmap image //Bitmap bitmap = BitmapFactory.decodeFile(mTmpImgFilePath); }/*from w ww . jav a2s . co m*/ cursor.close(); } else { // if user has selected a photo from Google Photo if (imgUri.toString().indexOf("com.google.android.apps.photos") > -1 && (imgUri.toString().indexOf("http%3A%2F%2F") > -1 || imgUri.toString().indexOf("https%3A%2F%2F") > -1)) { try { String imgUrl = imgUri.toString(); int urlStartIndex = (imgUri.toString().indexOf("http%3A%2F%2F") > -1) ? imgUri.toString().indexOf("http%3A%2F%2F") : imgUri.toString().indexOf("https%3A%2F%2F"); String remotePhotoUrl = URLDecoder.decode(imgUrl.substring(urlStartIndex), HTTP.UTF_8); mDialogHelper.toast("Downloading the selected image...", Toast.LENGTH_LONG); fetchRemotePhoto(remotePhotoUrl); } catch (UnsupportedEncodingException e) { String errMessage = "Failed to parse image URL."; Log.e(TAG, errMessage); mDialogHelper.toast(errMessage, Toast.LENGTH_SHORT, true); dismissSpinner(); } } // unsupported action else { mDialogHelper.toast("The app you selected is currently not supported."); } } } }
From source file:com.chaqianma.jd.fragment.CompanyInfoFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK) { switch (requestCode) { case REQUEST_SDK_IMGS: if (data != null && data.getData() != null) { Uri imgUri = data.getData(); ContentResolver resolver = getActivity().getContentResolver(); String[] pojo = { MediaStore.Images.Media.DATA }; Cursor cursor = null; try { cursor = resolver.query(imgUri, pojo, null, null, null); if (cursor != null && cursor.getCount() > 0) { int colunm_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); new Thread(new BaseFragment.ImgRunable(cursor.getString(colunm_index), Constants.BUSINESS_INFO, fileType, selCompanyIdxTag, new UpdateUIHandler())) .start(); } else { JDToast.showLongText(getActivity(), ""); }//from www . j a v a 2 s .c om } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (cursor != null) { cursor.close(); } } } break; case REQUEST_TAKE_PHOTO: new Thread(new BaseFragment.ImgRunable(Constants.TEMPPATH, Constants.BUSINESS_INFO, fileType, selCompanyIdxTag, new UpdateUIHandler())).start(); break; default: break; } } }
From source file:com.hackensack.umc.activity.ProfileSelfieManualCropActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case Constant.FRAGMENT_CONST_REQUEST_IMAGE_CAPTURE: if (resultCode == RESULT_OK) { /*Intent intent = new Intent(ProfileSelfieActivity.this, ActivityCropImage.class); intent.setData(imageUri);//from w w w . ja v a2 s . c o m startActivityForResult(intent, Constant.CROP_IMAGE_ACTIVITY);*/ //cropPictureIntent(imageUri); Intent intent = new Intent(ProfileSelfieManualCropActivity.this, ActivityCropImage.class); intent.setData(imageUri); // intent.putExtra(Constant.Cropp_InterFace, saveCroppedImage); intent.putExtra(Constant.SELECTED_IMAGE_VIEW, selectedImageView); startActivityForResult(intent, Constant.CROP_IMAGE_ACTIVITY); } break; default: if (resultCode == RESULT_OK) { try { if (data != null) { if (selectedImageView == Constant.SELFIE) { imageUri = data.getData(); /*CameraFunctionality.setPhotoToImageView(imageUri.toString(), imgSelfie, ProfileSelfieActivity.this); byte[] byteArray = getIntent().getByteArrayExtra(Constant.BITMAP_IMAGE); Bitmap bmp = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length); getImageUris(imageUri, 5,bmp,null);*/ Bitmap bitmapImage = data.getParcelableExtra(Constant.CROPPED_IMAGE); //bitmapImage=data.getParcelableExtra(Constant.CROPPED_IMAGE); //bitmapImage = CameraFunctionality.getBitmapFromFile(imageUri.toString(), ProfileSelfieManualCropActivity.this); // String base64=CameraFunctionality.readBasee64File(data.getStringExtra(Constant.BASE64_FILE_PATH)); // String base64 = Base64Converter.createBase64StringFromBitmap(bitmapImage, ProfileSelfieManualCropActivity.this); // String base64=Base64Converter.createBitmapFromFileImage(imageUri); String base64 = Base64Converter.createBase64StringFromBitmap(bitmapImage, ProfileSelfieManualCropActivity.this); getImageUris(imageUri, selectedImageView, null, base64); //CameraFunctionality.setPhotoToImageView(imageUri.toString(), imgIcFront, getActivity()); // CameraFunctionality.setBitMapToImageView(imageUri.toString(), bitmapImage, imgSelfie, ProfileSelfieManualCropActivity.this); //pathSelfie = imageUri; /* Bitmap bitmapImage = CameraFunctionality.unCompressedImage(data.getByteArrayExtra(Constant.BITMAP_IMAGE)); pathSelfie=Base64Converter.createBase64StringFroImage(bitmapImage,ProfileSelfieActivity.this);*/ txtSefileSet.setText(R.string.done); } } } catch (Exception e) { e.printStackTrace(); } } break; } }
From source file:com.fvd.nimbus.BrowseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); //overridePendingTransition(R.anim.carbon_slide_in,R.anim.carbon_slide_out); //overridePendingTransition(R.anim.activity_open_scale,R.anim.activity_close_translate); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); try {/*from w w w . j a v a 2 s .c o m*/ requestWindowFeature(Window.FEATURE_NO_TITLE); } catch (Exception e) { e.printStackTrace(); } clipData = new DataExchange(); isInitNow = true; setContentView(R.layout.screen_browser); serverHelper.getInstance().setCallback(this, this); prefs = PreferenceManager.getDefaultSharedPreferences(this); lastUrl = prefs.getString("LAST_URL", ""); saveCSS = prefs.getString("clipStyle", "1").equals("1"); ctx = this; //adapter = new TextAdapter(this); /*Uri data = getIntent().getData(); if(data!=null){ lastUrl=data.toString(); }*/ Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); if (Intent.ACTION_VIEW.equals(action) /*&& type != null*/) { Uri data = intent.getData(); if (data != null) { lastUrl = data.toString(); appSettings.appendLog("browse:onCreate " + lastUrl); } } else if (Intent.ACTION_SEND.equals(action) /*&& type != null*/) { if ("text/plain".equals(type)) { String surl = intent.getStringExtra(Intent.EXTRA_TEXT); if (surl.contains(" ")) { String[] arr = surl.replace("\t", " ").split(" "); for (String s : arr) { if (s.contains("://")) { lastUrl = s.trim(); break; } } } else if (surl.contains("://")) lastUrl = surl.trim(); appSettings.appendLog("browse:onCreate " + lastUrl); } } drawer = (DrawerLayout) findViewById(R.id.root); View v = findViewById(R.id.wv); wv = (fvdWebView) findViewById(R.id.wv); wv.setEventsHandler(this); //registerForContextMenu(wv); urlField = (AutoCompleteTextView) findViewById(R.id.etAddess); urlField.setSelectAllOnFocus(true); urlField.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { /*InputMethodManager imm = (InputMethodManager)v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0);*/ onNavButtonClicked(); return true; } else if (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { onNavButtonClicked(); return true; } return false; } }); onViewCreated(); handler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case 0: findViewById(R.id.bZoomStack).setVisibility(View.VISIBLE); findViewById(R.id.bToggleMenu).setVisibility(View.GONE); break; default: break; } } }; navButton = (ImageButton) findViewById(R.id.ibReloadWebPage); navButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //Toast.makeText(getApplicationContext(), "You made a mess", Toast.LENGTH_LONG).show(); onNavButtonClicked(); } }); findViewById(R.id.bSavePageFragment).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //toggleTools(); floatMenu.collapse(); if (!wv.getInjected()) Toast.makeText(ctx, getString(R.string.wait_load), Toast.LENGTH_LONG).show(); clipMode = 2; if (wv.getInjected()/* && !v.isSelected()*/) { wv.setCanClip(true); v.setSelected(true); Toast.makeText(ctx, ctx.getString(R.string.use_longtap), Toast.LENGTH_LONG).show(); } } }); (findViewById(R.id.bSaveFullPage)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { floatMenu.collapse(); if (wv.getInjected()) { wv.setCanClip(false); wv.saveArticle(); clipMode = 1; progressDialog = ProgressDialog.show(v.getContext(), "Nimbus Clipper", getString(R.string.please_wait), true, false); } else { Toast.makeText(ctx, getString(R.string.wait_load), Toast.LENGTH_LONG).show(); } } }); findViewById(R.id.bTakeScreenshot).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { //toggleTools(); floatMenu.collapse(); findViewById(R.id.bSaveFullPage).setVisibility(View.GONE); findViewById(R.id.bSavePageFragment).setVisibility(View.GONE); findViewById(R.id.bTakeScreenshot).setVisibility(View.GONE); if (wv.getInjected()) { wv.setCanClip(false); } findViewById(R.id.bToggleMenu).setVisibility(View.GONE); /*screenCapture(); findViewById(R.id.bToggleMenu).setVisibility(View.VISIBLE);*/ findViewById(R.id.bTakeScreenshot).postDelayed(new Runnable() { @Override public void run() { // TODO Auto-generated method stub screenCapture(); findViewById(R.id.bToggleMenu).setVisibility(View.VISIBLE); finish(); } }, 10); //showDialog(DIALOG_CAPTURE); } }); (findViewById(R.id.bDone)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { { try { wv.setCanClip(false); wv.endSelectionMode(); //findViewById(R.id.bSavePageFragment).setSelected(false); clipMode = 2; wv.endSelectionMode(); String selHtml = clipData.getContent(); if (selHtml.length() > 0) { String ss = selHtml.substring(0, selHtml.indexOf(">") + 1).toLowerCase(); int j = ss.indexOf("<div"); if (j == 0) { j = ss.indexOf("style"); if (j > 0) { int k = ss.indexOf("\"", j + 11); if (k > 0) selHtml = selHtml.replace(selHtml.substring(j, k + 1), ""); } //selHtml="<DIV>"+selHtml.substring(ss.length()); } clipData.setContent(selHtml); clipData.setTitle(wv.getTitle()); /*if (true){ if(sessionId.length() == 0 || userPass.length()==0) showSettings(); else { if(prefs.getBoolean("check_fast", false)){ sendNote(wv.getTitle(), clipData.getContent(), parent, tag); clipData.setContent(""); } else { //serverHelper.getInstance().setCallback(this,this); if(appSettings.sessionId.length()>0) { serverHelper.getInstance().sendRequest("notes:getFolders", "",""); } } } wv.endSelectionMode(); } */ Intent i = new Intent(getApplicationContext(), previewActivity.class); i.putExtra("content", clipData); startActivityForResult(i, 5); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); } //clipData.setContent(""); } catch (Exception e) { BugReporter.Send("onEndSelection", e.getMessage()); } } //showDialog(DIALOG_CAPTURE); } }); findViewById(R.id.bZoomIn).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { wv.ZoomInSelection(); } }); findViewById(R.id.bZoomOut).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { wv.ZoomOutSelection(); } }); setNavButtonState(NavButtonState.NBS_GO); progressBar = (ProgressBar) findViewById(R.id.progressbar); //CookieSyncManager.createInstance(this); //webSettings.setLoadsImagesAutomatically(imgOn); userMail = prefs.getString("userMail", ""); userPass = prefs.getString("userPass", ""); sessionId = prefs.getString("sessionId", ""); appSettings.sessionId = sessionId; appSettings.userMail = userMail; appSettings.userPass = userPass; if ("1".equals(prefs.getString("userAgent", "1"))) { wv.setUserAgent(null); } else wv.setUserAgent(deskAgent); final Activity activity = this; //lastUrl="file:///android_asset/android.html"; if (lastUrl.length() > 0) { //wv.navigate(lastUrl); //if(!urlField.getText().toString().equals(wv.getUrl())) urlField.setText(lastUrl); openURL(); } isInitNow = false; urlField.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int position, long id) { // TODO Auto-generated method stub /*String item = (String)parent.getItemAtPosition(position); Toast.makeText( getApplicationContext(), " " + item, Toast.LENGTH_SHORT).show();*/ openURL(); } }); urlField.addTextChangedListener(this); parent = prefs.getString("remFolderId", "default"); /*ListView listView = (ListView) findViewById(R.id.left_drawer); listView.setAdapter(new DrawerMenuAdapter(this,getResources().getStringArray(R.array.lmenu_browser))); listView.setOnItemClickListener(this);*/ }
From source file:org.planetmono.dcuploader.ActivityUploader.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK) { if (requestCode == Application.ACTION_ADD_PHOTO || requestCode == Application.ACTION_TAKE_PHOTO) { /* add photo */ if (contents.size() == 5) return; Uri selectedImage;// w w w . j a v a2s. c o m Bitmap tbm; if (requestCode == Application.ACTION_ADD_PHOTO) { selectedImage = data.getData(); tbm = getBitmapThumbnail(selectedImage); } /*else if (requestCode == Application.ACTION_TAKE_PHOTO && data != null && data.hasExtra("data")) { Bundle b = data.getExtras(); String mpath = null; Bitmap bitmap = (Bitmap) b.get("data"); try { if (tempFile == null) { File f = File.createTempFile("dcuploader_photo_", ".jpg", Environment .getDownloadCacheDirectory()); FileOutputStream fo = new FileOutputStream(f); mpath = f.getAbsolutePath(); bitmap.compress(CompressFormat.JPEG, 90, fo); fo.close(); } else { mpath = tempFile.getAbsolutePath(); tempFile = null; } } catch (IOException e) { e.printStackTrace(); return; } selectedImage = Uri.parse("file://" + mpath); tempFiles.add(mpath); tbm = getBitmapThumbnail(bitmap); bitmap.recycle(); } */else { /* take photo */ selectedImage = Uri.fromFile(tempFile); tempFiles.add(tempFile.getAbsolutePath()); tbm = getBitmapThumbnail(selectedImage); } Gallery g = (Gallery) findViewById(R.id.upload_images); int npos = 0; int pos = g.getSelectedItemPosition(); if (pos == -1 || pos == 3) { contents.add(selectedImage); bitmaps.add(tbm); if (pos == 3) npos = pos + 1; } else { contents.add(pos + 1, selectedImage); bitmaps.add(pos + 1, tbm); npos = pos + 1; } updateGallery(); updateImageButtons(); g.setSelection(npos); galleryChanged = true; } else if (requestCode == Application.ACTION_ADD_GALLERY) { /* add gallery */ DatabaseHelper db = new DatabaseHelper(ActivityUploader.this); db.setFavorites(data.getStringArrayExtra("result")); db.close(); openContextMenu(findViewById(R.id.upload_target)); } else if (requestCode == Application.ACTION_SIGN_ON) { /* when signed on, go on. */ publish(); } else if (requestCode == Application.ACTION_PREFERENCES) { /* apply preferences */ Log.d(Application.TAG, "reloading configuration..."); reloadConfigurations(); setDefaultImage(); queryLocation(formLocation); } } }