Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For <strong>uploading</strong> images to a server from your application you can follow following tutorials:</p> <ol> <li><p><a href="http://stunningco.de/2010/04/25/uploading-files-to-http-server-using-post-android-sdk/" rel="nofollow noreferrer"><strong>Uploading files to HTTP server using POST on Android.</strong></a></p></li> <li><p><a href="http://vikaskanani.wordpress.com/2011/01/11/android-upload-image-or-file-using-http-post-multi-part/" rel="nofollow noreferrer"><strong>Upload image or file using http POST multi-part.</strong></a></p></li> </ol> <p>The above two url will explain you how to upload images from your application to server.</p> <p>For uploading image from your photo gallery you require the path of that image file and replace the obtained path with <code>/data/file_to_send.mp3</code> in first url.</p> <p>To obtain path of the image from the mobile gallery you can follow the following code:</p> <pre><code> @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); b1 = (Button)findViewById(R.id.Button01); b1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { openGallery(SELECT_FILE1); } }); } public void openGallery(int req_code) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select file to upload "), req_code); } public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK) { Uri selectedImageUri = data.getData(); if (requestCode == SELECT_FILE1) { selectedPath1 = getPath(selectedImageUri); System.out.println("selectedPath1 : " + selectedPath1); } if (requestCode == SELECT_FILE2) { selectedPath2 = getPath(selectedImageUri); System.out.println("selectedPath2 : " + selectedPath2); } tv.setText("Selected File paths : " + selectedPath1 + "," + selectedPath2); } } public String getPath(Uri uri) { String[] projection = { MediaStore.Images.Media.DATA }; Cursor cursor = managedQuery(uri, projection, null, null, null); int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); return cursor.getString(column_index); } </code></pre> <p>for downloading images you can do the following code.</p> <pre><code> ImageView image = (ImageView)findViewById(R.id.image); if(!ImageUrl.equals("no image")) { try { image.setImageDrawable(grabImageFromUrl(ImageUrl)); } catch(Exception e) { } } private Drawable grabImageFromUrl(String url) throws Exception { return Drawable.createFromStream((InputStream)new URL(url).getContent(), "src"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload