Question: If I want to design a button that all java can use it without need to write it in every java,
what should I do? 

For Example:
I design a Button.OnClickListener function to search bluetooth devices.
but another java also need to use this Button.OnClickListener function,
I don't want to write same way on two java.

ledWrite.xml:

```
<Button android:id="@+id/btnScan" />
<ToggleButton android:id="@+id/tBtnWrite" />

```

bluetoothUtils.java

```
// Intent request codes
private static final int REQUEST_CONNECT_DEVICE = 1;

private Button button_scan;
button_scan = (Button)findViewById(R.id.button_scan);
button_scan.setOnClickListener(new OnClickListener(){
  public void onClick(View v) {
        scanbt(); 
  }
});

private void scanbt(){
   Intent serverIntent = new Intent(this, DeviceListActivity.class);
   startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE); 
}

```

then I design LedWrite.java:

```
private ToggleButton digitalOutBtn; //LED On/OFF
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ledwrite);

digitalOutBtn = (ToggleButton)findViewById(R.id.tBtnWrite);
digitalOutBtn.setOnClickListener(new OnClickListener()
public void onClick(View v){
  if(digitalOutBtn.isChecked()){ //sendMessage("D1"); }
   else{sendMessage("D0";}
}

```

How can I use button\_scan in LedWrite.java?

Answer: 
You can use Python's `paramiko` package to launch a program on the server via ssh. That program would then in turn receive commands (perhaps via stdin) and return results (via stdout) from the controlling program. So basically you'll use `paramiko.SSHClient` to connect to the server and run a second Python program which itself uses e.g. `telnetlib` to talk to the device.
Use tunneling by setting up a `SSH` session that tunnels the `Telnet` traffic:
So ssh from `localhost` to `server` with the option `-L xxx:deviceip:23`
(xxx is a free port on localhost, device is the IP address of "device", 23 is the telnet port).

Then open a telnet session on your localhost to localhost:xxx. SSH will tunnel it to the device and response is sent back to you.