Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7899319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:40:14+00:00 2026-06-03T08:40:14+00:00

Am working on some application. However, i have finished two modules which invoke the

  • 0

Am working on some application. However, i have finished two modules which invoke the phones’ native camera to take a snapshot and an also record a video. I intend to use the phone application to send the image and the video taken and recorded by the phone to a website i intend to create. However, for textual information, i could store the information as strings, for the image and the video, i am not sure if i should leave them as Uris upon submission. Below is my picture, and video programs respectively. Thanx
Picture code:

package com.project;

import java.io.File;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class MyPicture extends Activity {
    /** Called when the activity is first created. */
    /*constant and variable created so as to work with the taken pictures*/
    private static int TAKE_PICTURE = 1;
    private Uri outputFileUri;
    Uri imageUri;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.pic);
        Button pictureButton=(Button) findViewById(R.id.pictureButton);
        pictureButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                File file = new File(Environment.getExternalStorageDirectory(),"test.jpg");
                outputFileUri = Uri.fromFile(file);
                intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
                startActivityForResult(intent, TAKE_PICTURE);

            }
        });
    }
    @Override
    protected void onActivityResult(int requestCode,int resultCode, Intent data){
        if (requestCode == TAKE_PICTURE){
            imageUri = data.getData();
            //do something about the image in the in outputFileUri
            Toast.makeText(MyPicture.this,
                    "Picture successfully taken",
                    Toast.LENGTH_SHORT).show();
                    Intent i = new Intent(MyPicture.this,/*program execution proceeds back to MyPicture, our start page after success of image takin*/
                            Myindex.class);
                    startActivity(i);

        }else{
            Toast.makeText(MyPicture.this,
                    "Picture Unsuccessfully taken",
                    Toast.LENGTH_SHORT).show();
                    Intent i = new Intent(MyPicture.this,/*program execution proceeds back to MyPicture, so we can redo the recording*/
                            MyPicture.class);
                    startActivity(i);
        }

    }
} 

Video code:

package com.project;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class MyVideo extends Activity {
    /*program for the vid button*/
    private static int  RECORD_VIDEO = 1;
    private static int HIGH_VIDEO_QUALITY = 1;
    //private static int MMS_VIDEO_QUALITY = 0;
    Uri recordedVideo;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.vid);
        Button videoButton=(Button) findViewById(R.id.videoButton);
        videoButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
                //intent.putExtra(MediaStore.EXTRA_OUTPUT, output);
                intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, HIGH_VIDEO_QUALITY);
                startActivityForResult(intent, RECORD_VIDEO);
            }
        });
    }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data){
        if (requestCode == RECORD_VIDEO){
            recordedVideo = data.getData();
            //to do something with the recorded video
            //we shall insert this information in the database
            Toast.makeText(MyVideo.this,
                    "Video successfully recorded",
                    Toast.LENGTH_SHORT).show();
                    Intent i = new Intent(MyVideo.this,/*program execution proceeds back to Myindex, our start page*/
                            Myindex.class);
                    startActivity(i);
        }
        else{
            /*Happens after unsuccessfull recording of video*/
            Toast.makeText(MyVideo.this,
                    "Video Unsuccessfully recorded",
                    Toast.LENGTH_SHORT).show();
                    Intent i = new Intent(MyVideo.this,/*program execution proceeds back to MyVideo, so we can redo the recording*/
                            MyVideo.class);
                    startActivity(i);
        }

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T08:40:16+00:00Added an answer on June 3, 2026 at 8:40 am

    For images what I usually do is to decode the data as a Bitmapand then I send it via Http Post using the multipart content-type.

    You can decode the image file as a Bitmap using: BitmapFactory.decodeFile.

    Here is an example of how I send the Bitmap with multipart using the Apache library:

    public String doHttpMultipart(String url, 
                                      List<NameValuePair> pairs,
                                      Bitmap bitmap,
                                      String fileName) throws IOException, 
                                                    ClientProtocolException,
                                                    UnsupportedEncodingException {
                ByteArrayOutputStream bos = new ByteArrayOutputStream();        
                bitmap.compress(CompressFormat.PNG, 100, bos);
                byte[] imageData = bos.toByteArray();
                ByteArrayBody byteArrayBody = new ByteArrayBody(imageData, fileName);
                MultipartEntity reqEntity = 
                            new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
    
                reqEntity.addPart("image", byteArrayBody);
    
                for(NameValuePair p : pairs) {
                    reqEntity.addPart(p.getName(), new StringBody(p.getValue()));
                }
    
                HttpPost request = new HttpPost(url);
                request.setEntity(reqEntity);
    
                HttpClient client = new DefaultHttpClient();
                HttpResponse httpResponse = client.execute(request);
    
                String response = "";
                BufferedReader in = null;
    
                try {
                    response = super.readHttpStream(response, in, httpResponse);    
                } catch(IllegalStateException e) {
                    throw new IllegalStateException();
                } catch(IOException e) {
                    throw new IOException();
                } finally {
                    if (in != null) {
                        try {
                            in.close();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }
    
                return response;
            }
    

    For a video file, it should be the same you should see how to decode it as an array of bytes and send it with multipart.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a Rails application where I have some a set of two
I have a Phonegap/jQuery application which is working great, however in one area the
I am working on an application which has got some sensitive information. I am
I am working on an iPhone application which lists some items in a Table
I have to modify some code in a application I am working on that
I am working on a Google App Engine application, and have been facing some
I am working on a web-based application using asp.net 4.0. I have some dlls
I am working on some Cucumber stories for a 'sign up' application which has
I have an AudioQueue based application working almost perfectly. I'm suffering an issue, however.
GAE 1.5.5 looks to have some excellent, long-waited for features. However, they're not working

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.