I have had a lot of problems to send data(a string of length 250 000)
to a server using java. I have probe a lot of things:
1. send byte by byte
i send 40Mbytes instead of 1Mbyte of data to server(because i use a
cicle "for()"and TCP/IP header add 40bytes and data is 1byte)
int ncc = 250 000
for(int a =0;a<ncc;a++){
out2.writeByte(utf8[a]);
}
only here i spend 15 seg counting with my watch (garbage
collector(GC) add 1,5 seg if Log info is correct)
2. send a string of length 250 000(in other words has 250 000
characters)
out2.writeByte(st);
//where st is a string
Here GC go crazy and the time is so large than i did't count it(maybe
near to infinite XD)
Now i think the best option is use NDK for send data, but i think is
hard to use and understand
I will be in debt with you if you can post info about how i can create
a good code to use socket with NDK. Please share info about how can i
learn to use the ndk, recomendation are wellcame. Seriously NDK is my
last hope
On Aug 13, 2:29 am, "nikko.aiello" <[email protected]> wrote:
> using MediaRecorder or AudioTrack??
>
> an easy way with MediaRecorder is like so...
>
> MediaRecorder mMediaRecorder = new MediaRecorder();
> ...
> FileDescriptor fd =
> ParcelFileDescriptor.fromSocket(mAudioOutSocket).getFileDescriptor();
> mMediaRecorder.setOutputFile(fd);
>
> OR
>
> For AudioTrack, you should use a background thread to read the data
> into a buffer and thensendthe bytes to yourserver. Make sure you
> set a high priority for that thread:
>
> android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
>
> In my case, the best (fastest) solution was to use the ndk and read
> from AudioTrack in a native thread, andsendthe data using C sockets.
>
> -nick-
>
> On Aug 13, 12:45 am, cindy <[email protected]> wrote:
>
> > My application needs tosenddata toserverwhile recording the audio
> > data?
>
> > Does anyone know how to do that?
>
> > Thanks!
>
> > April
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en