Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Bluetooth SPP is sending data from AnalogReadSerial.ino of Arduino to my Android Phone. Those Value will be used to display using GaugeView.
Use this:
String myString;
void setup()
{
Serial.begin(300);
//Sets the data rate in bits per second (baud) for serial data transmission. For communicating with the computer, use one of these rates: 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, or 115200.
//You can, however, specify other rates - for example, to communicate over pins 0 and 1 with a component that requires a particular baud rate.
}
void loop()
{
while (Serial.available())
{
myString = Serial.readString();
//the rest of the code..
}
}
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want to save an a value for example my full name(something that never changes and i will re-use it again all the time).I would like it to save it locally i guess.
String str = "abc";
Toast.makeText(getActivity(), "This is my Toast message!" + str ,Toast.LENGTH_LONG).show();
If you want to save small amount of data, like key-value pairs, eg. Name=somename, uimode=dark etc., then you can use Shared Preferences. If you want to save huge amount of data, then you must save it in database (SQLite or other one)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am making an android app where i should send camera frames via udp/tcp socket
I get each frame as a byte[] array in a FrameCallback
Then i used the socket to send each time MAX_BUFFER_SIZE bytes from the array
as fragments.
But it's not Effcient enough since the array size sent is about 10M, and there will be alot of buffering when the stream will be desplayed.
I can't compress the array too since it's an OMEGA(n) operation, SO
First of all , what protocol is better for this problem? UDP, TCP ?
And in general , how can i send that huge array over socket in a video streaming efficiency level ?
I solved it by using the UDP Protocol
And used Allocation class to compress the data array, it did the work!
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
So I'm using the SerialPort class to read data from a serial device. my code is as shown below. I researched a little and found out that serial data is read at 100kb/sec. So according to that, my program would have to read the data in just 2 seconds since I have called the readHexString function with 200000 as a parameter and it thus reads 200000 bytes, I just want to know why it takes many minutes to read the data serially?
serialPort.openPort();
serialPort.setParams(SerialPort.BAUDRATE_57600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
int count = 0;
String data = serialPort.readHexString(200000);
You can not assume 100kb/sec
That leads to 34,722 seconds for 2000000 Bytes
I'd like to ask if your device is sending continuously Data? Your Code reads 200.000 Bytes. So you have to wait until the Buffer is full. You could try to cycle smaller amount of data and break if a marker is reached.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to create a server which receives both text and image. For text I used DataInputStream dis.readUTF(), and for image, I used ObjectInputStream ois.readObject() to read the image as byte[]. So how can I write code to detect the data receiving is text or byte[]?
You'll have to use some kind of signal from the client to know whether it is sending text or an image.
Alternatively, you could receive on different ports depending on the type of input.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
How would i play a specific song in iTunes through java?
I assume I need to somehow connect to iTunes and use the play function with a certain parameter....Can anyone point me in the right direction to learning how to do this?
According to that answer, there is no API. There is only an SDK (via COM) for Windows.
In Mac OS, iTunes is controlled via AppleScript(example).
Ik it's too late, but u can use apple script editor. for instance,
Runtime runtime = Runtime.getRuntime();
String[] args = {"osascript" , "-e" , "tell application \"iTunes\" to play"};
try{
Process process = runtime.exec(args);
}catch (Exception ex) {
}
this will play a song in itunes