Android Open Source - android-robot-control-app Controller Fragment






From Project

Back to project page android-robot-control-app.

License

The source code is released under:

GNU General Public License

If you think the Android project android-robot-control-app 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 will.st.bluetooth.robot.controller.controllers;
/*  w ww .  j  a  v  a 2s  .  c  o m*/
import java.io.IOException;
import java.io.OutputStream;

import android.support.v4.app.Fragment;
import android.util.Log;

public abstract class ControllerFragment extends Fragment {

  private static final String TAG = "ROBOT_CONTROLLER";
  
  protected OutputStream mOutputStream = null;
  
  public ControllerFragment(OutputStream outputStream) {
    this.mOutputStream = outputStream;
  }

  @Override
  public void onPause() {
    super.onPause();
    Log.d(TAG, "...In ControllerFragment onPause()...");
    mOutputStream = null;
    
  }
  
  // Sends a String over Bluetooth as a series of bytes.
  protected void sendData(String message) {
    Log.d(TAG, "...In ControllerFragment sendData()...");
    byte[] msgBuffer = message.getBytes();
    try {
      mOutputStream.write(msgBuffer);
    } catch (IOException e) {
      Log.e(TAG,
          "In sendData(String message) an exception occurred during write",
          e);
    }
  }
}




Java Source Code List

will.st.bluetooth.robot.controller.BtConnectFragment.java
will.st.bluetooth.robot.controller.ConnectionFailedException.java
will.st.bluetooth.robot.controller.ControllerActivity.java
will.st.bluetooth.robot.controller.CrabToyFragment.java
will.st.bluetooth.robot.controller.MainMenuActivity.java
will.st.bluetooth.robot.controller.ToyMenuActivity.java
will.st.bluetooth.robot.controller.TwoWheelToyFragment.java
will.st.bluetooth.robot.controller.controllers.ControllerFragmentFactory.java
will.st.bluetooth.robot.controller.controllers.ControllerFragment.java
will.st.bluetooth.robot.controller.controllers.XControllerFragment.java