Android Open Source - GeoCarDroid Geo Send Data Thread






From Project

Back to project page GeoCarDroid.

License

The source code is released under:

GNU General Public License

If you think the Android project GeoCarDroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.geocar.bluetooth;
/*from  ww w .j a  v a  2  s .c om*/
import java.io.IOException;
import java.io.OutputStream;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;

public class GeoSendDataThread extends ConnectThread {
  private char[] mMessages;
  
  @Override
  protected void onConnected(BluetoothSocket socket) {
    // Do work to manage the connection (in a separate thread)
    try {
      // flush out message
      OutputStream outStream = socket.getOutputStream();
      for (char msg : mMessages) {
        outStream.write(new byte[] { (byte) msg });
      }      
      sleep(200);
      outStream.flush();
      sleep(1000);
      outStream.close();
      sleep(3000);      
      outStream = null;
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (InterruptedException e) {
      // exception for sleep
      e.printStackTrace();
    }

    cancel();
  }

  public GeoSendDataThread(BluetoothDevice device, String uuid, char[] msgs) {
    super(device, uuid, null);
    mMessages = msgs;
    
  }

  

}




Java Source Code List

com.geocar.bluetooth.AlertType.java
com.geocar.bluetooth.BthDeviceManager.java
com.geocar.bluetooth.ConnectThread.java
com.geocar.bluetooth.ConnectedThread.java
com.geocar.bluetooth.ConnectionHandler.java
com.geocar.bluetooth.GeoSendDataThread.java
com.geocar.bluetooth.SocketHandler.java
com.geocar.geocarconnect.FileInfo.java
com.geocar.geocarconnect.FileManager.java
com.geocar.geocarconnect.GeoCarAlert.java
com.geocar.geocarconnect.MainActivity.java
com.geocar.geocarconnect.PrefActivity.java
com.geocar.geocarconnect.Settings.java
com.geocar.geocarconnect.StartMenu.java
com.geocar.sms.SmsListener.java