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

  • SEARCH
  • Home
  • 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 8569411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:19:41+00:00 2026-06-11T18:19:41+00:00

I am trying to send the send voice data immediately to local server using

  • 0

I am trying to send the send voice data immediately to local server using audiorecord.. I am able to record the voice & stores it in SDcard.. but I want to store audio voice in buffer & sends immediate to the server using HTTP POST. How can I proceed.got struck..? I am creating this app in ICS i.e android 4.0.3 version.

  • 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-11T18:19:42+00:00Added an answer on June 11, 2026 at 6:19 pm

    got the solutions.. sending voice data as a jsonarray to server & recieve back as a json object. convert back jsonobject to short array n write to audiotrack then play back. here is sample code working.

     public void SendAudio() {
    
        String LOG_TAG = null;
        long SAMPLE_INTERVAL = 1;
    
        Log.e(LOG_TAG, "start send thread, thread id: ");
    
        int bytes_read = 0;
        int bytes_count = 0;
    
        br = br % 5;
        br++;
        try {
            HttpClient httpclient = new DefaultHttpClient();
            HttpClient httpclient_recv = new DefaultHttpClient();
            // System.out.println("mmdata--------- " + value);
            HttpPost httppost = new HttpPost("http://192.168.1.39/call");
            HttpPost httppost_recv = new HttpPost("http://192.168.1.39/ping");
            // Unix time stamp
            long unixTime = System.currentTimeMillis();
            String timestamp = String.valueOf(unixTime);
    
            // Json Format
            JSONObject holder = new JSONObject();
            JSONObject holder_recv = new JSONObject();
            JSONArray jArray = new JSONArray();
            try {
    
                holder.put("UserId", "1");
                holder.put("TimeStamp", timestamp);
                holder.put("SessionId", "1");
    
                Queue<byte[]> qArray = new LinkedList<byte[]>();
                qArray.add(bData);
    
                byte[] tmparr = qArray.poll();
                for (int i = 0; i < tmparr.length; i++) {
                    jArray.put(i, tmparr[i]);
                }
                System.out.println("send audio -- " + jArray);
                holder.put("MMData", jArray.toString());
                System.out.println("JSON -- " + holder.toString());
    
                holder_recv.put("UserId", "1");
                holder_recv.put("TimeStamp", timestamp);
                holder_recv.put("SeqNo", "100");
                holder_recv.put("SessionId", "0");
    
            } catch (JSONException e1) {
                e1.printStackTrace();
            }
            System.out.println("time " + timestamp);
            try {
    
                StringEntity se = new StringEntity(holder.toString());
                StringEntity se_recv = new StringEntity(holder_recv.toString());
    
                se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE,
                        "application/json"));
                se_recv.setContentType(new BasicHeader(HTTP.CONTENT_TYPE,
                        "application/json"));
    
                httppost.setEntity(se);
                httppost_recv.setEntity(se_recv);
                HttpResponse response = httpclient.execute(httppost);
                HttpResponse response_recv = httpclient_recv
                        .execute(httppost_recv);
    
                if (response_recv != null) {
                    t = EntityUtils.toString(response_recv.getEntity());
                    System.out.println("after response -- " + t);
                    Queue<String> qe = new LinkedList<String>();
                    qe.add(t);
    
                    t = null;
                    System.out.println("on play side ...1 ");
                    try {
                        System.out.println("on play side ...2 ");
                        JSONObject get = new JSONObject(qe.poll());
    
                        // JSONArray jArray_recv = get.getJSONArray("MMData");
    
                        String mmdata = (String) get.get("MMData");
                        JSONObject temp2 = new JSONObject("{ \"MMData\" : "
                                + mmdata + "}");
                        JSONArray jArray_recv = temp2.getJSONArray("MMData");
                        System.out.println("jsonarray -- " + jArray_recv);
                        // String timeData = (String) get.get("TimeStamp");
                        String userData = (String) get.get("UserId");
                        // String sessionId = (String) get.get("TimeStamp");
                        System.out.println("on play side ...3 ");
                        // if (Long.valueOf(timeData) > ts)
                        {
                            // ts = Long.valueOf(timeData);
                            System.out.println("on play side ...4 ");
                            if (at != null) {
                                System.out.println("on play side ...5 ");
                                byte[] shortArray = new byte[jArray_recv
                                        .length()];
                                for (int i = 0; i < jArray_recv.length(); i++) {
                                    shortArray[i] = (byte) jArray_recv
                                            .getInt(i);
                                }
                                jArray_recv = null;
                                System.out.println("recv audio -- " + br
                                        + " ----" + shortArray);
                                byte[] temp = shortArray;
                                shortArray = null;
    
                                byte[] bArray = temp;
                                temp = null;
                                byte[][] newbarray = new byte[5][1024];
                                newbarray[br - 1] = bArray;
                                byte[] sbayyay = new byte[1024 * 5];
                                System.arraycopy(bArray, 0, sbayyay,
                                        (br - 1) * 1024, bArray.length);
                                if (br == 5) {
                                    for (int i = 0; i < 5; i++) {
                                        System.out.println("in for---" + i
                                                + "----" + sbayyay.length);
                                        // System.arraycopy(newbarray[i], 0,
                                        // sbayyay, i * 1024,
                                        // bArray.length);
                                    }
                                    System.out.println("bsbsbsbs --- "
                                            + new String(sbayyay));
                                    at.write(sbayyay, 0, sbayyay.length);
                                    at.play();
    
                                }
    
                            }
    
                            else {
                                Log.d("Audio",
                                        "audio track is not initialised ");
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
    
                    }
                }
            } catch (ClientProtocolException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (Exception e) {
                System.out.println("Exception");
                e.printStackTrace();
            }
            bytes_count += bytes_read;
            Log.d(LOG_TAG, "bytes_count : " + bytes_count);
            Thread.sleep(SAMPLE_INTERVAL, 0);
        } catch (InterruptedException ie) {
            Log.e(LOG_TAG, "InterruptedException");
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to record a audio & stores into a sdcard as well
Im trying to send images over HTTP using HttpListener but some images come from
am trying send an array to php file using $_POST ,still always getting an
I`m trying to send simple html page with form data to user with GET,
I am trying to send emails from smtps (secure smtp) using Indy and the
I am trying to send data as a model from an html form to
Trying to send POST request on click event using jQuery with no luck. Here
Im trying to send ascii encoded message to a server. My problem is coming
Im trying to send simple login/password parameters to my PHP file in my server
I am trying to send data from a C#.NET (Windows Application) program to a

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.