0
我正在爲藍牙熱敏打印機做一個應用程序。我已經完成了打印部分。startService(sendIntent)發射不止一次
這是代碼:
public void printText(View view)
{
Button b = (Button)findViewById(R.id.button2);
if (b.getText().toString().equals("Choose Printer"))
errorAlert("No Printer Selected");
else
{
EditText e = (EditText)findViewById(R.id.printerText);
errorAlert("Printing...");
Intent sendIntent = new Intent();
stopService(sendIntent);
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra("MAC", mac);
sendIntent.putExtra("DATA", e.getText().toString()+"\n\n");
sendIntent.setComponent(new ComponentName("com.example.bluetoothtest",""com.example.bluetoothtest.MainActivity""));
startService(sendIntent);
}
}
當我調用printText打印機打印兩次或三次。似乎startService(sendIntent)不止一次觸發。