Buenas Noches estoy desarrollando una app en la que me comunico con un lector de tarjetas. me pasaron un demo en la cual usan la libreria del dispositivo.
mi app logra conectarse con el dispositivo usando la clase y usando algunas funciones dentro del activitie me funciona pero al momento de usar las funciones en otros activities se pierde la conexion bluettoth con el dispositivo.
me imagino que estoy haciendo mal el llamado de la libreria porfa me gustaria saber como se hace.. e intentado de muchas formas y nada no me funciona. la verdad es que me cuesta el manejo de clases.
la activity donde me funciona
Código:
package com.example.mobilevpos;
import com.bbpos.wisepad.WisePadController;
import com.bbpos.wisepad.WisePadController.BatteryStatus;
import com.bbpos.wisepad.WisePadController.CheckCardResult;
import com.bbpos.wisepad.WisePadController.DisplayText;
import com.bbpos.wisepad.WisePadController.EmvOption;
import com.bbpos.wisepad.WisePadController.PinEntryResult;
import com.bbpos.wisepad.WisePadController.WisePadControllerListener;
public class Conectar extends Activity {
private EditText statusEditText;
private ListView appListView;
private Dialog dialog;
private ProgressBar BarraConectar;
private Button BtnContinuar;
public WisePadController wisePadController;
public MyWisePadControllerListener listener;
public String amount = "";
public String cashbackAmount = "";
public boolean isPinCanceled = false;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.conectar);
statusEditText = (EditText)findViewById(R.id.statusEditText);
BarraConectar = (ProgressBar)findViewById(R.id.progressBar1);
BtnContinuar = (Button)findViewById(R.id.conectar);
BtnContinuar.setVisibility(View.INVISIBLE);
listener = new MyWisePadControllerListener();
wisePadController = new WisePadController(this, listener);
statusEditText.setText(R.string.connecting_bluetooth);
wisePadController.startBTv2(new String[] {"iBT-02 Demo", "WisePad"});
}
public void continuar(View view) {
//BtnContinuar.setEnabled(false);
//wisePadController.checkCard();
Intent i = new Intent(this, Botones.class ); /*metodo que abre la ventana de tipo de cuenta */
startActivity(i);
}
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.activity_main, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item)
{
if(item.getItemId() == R.id.menu_get_deivce_info)
{
statusEditText.setText(R.string.getting_info);
wisePadController.getDeviceInfo();
}
else if(item.getItemId() == R.id.menu_disconnect_bluetooth)
{
wisePadController.stopBTv2();
}
return true;
}
public void onPause() {
super.onPause();
}
public void dismissDialog() {
if(dialog != null) {
dialog.dismiss();
dialog = null;
}
}
class MyWisePadControllerListener implements WisePadControllerListener {
@Override
public void onWaitingForCard() {
statusEditText.setText(getString(R.string.waiting_for_card));
}
@Override
public void onBTv2Connected(BluetoothDevice bluetoothDevice) {
statusEditText.setText(getString(R.string.bluetooth_connected) + ": " + bluetoothDevice.getAddress());
BarraConectar.setVisibility(View.INVISIBLE);
BtnContinuar.setVisibility(View.VISIBLE);
}
@Override
public void onBTv2Detected() {
statusEditText.setText(getString(R.string.bluetooth_detected));
}
@Override
public void onBTv2Disconnected() {
statusEditText.setText(getString(R.string.bluetooth_disconnected));
}
@Override
public void onReturnCheckCardResult(CheckCardResult checkCardResult, Hashtable<String, String> decodeData) {
dismissDialog();
if(checkCardResult == CheckCardResult.NONE)
{
statusEditText.setText(getString(R.string.no_card_detected));
}
else if(checkCardResult == CheckCardResult.ICC)
{
statusEditText.setText(getString(R.string.icc_card_inserted));
wisePadController.startEmv(EmvOption.START);
}
else if(checkCardResult == CheckCardResult.NOT_ICC)
{
statusEditText.setText(getString(R.string.card_inserted));
}
else if(checkCardResult == CheckCardResult.BAD_SWIPE)
{
statusEditText.setText(getString(R.string.bad_swipe));
}
else if(checkCardResult == CheckCardResult.MCR)
{
String formatID = decodeData.get("formatID");
String maskedPAN = decodeData.get("maskedPAN");
String expiryDate = decodeData.get("expiryDate");
String cardHolderName = decodeData.get("cardholderName");
String ksn = decodeData.get("ksn");
String serviceCode = decodeData.get("serviceCode");
String track1Length = decodeData.get("track1Length");
String track2Length = decodeData.get("track2Length");
String track3Length = decodeData.get("track3Length");
String encTracks = decodeData.get("encTracks");
String encTrack1 = decodeData.get("encTrack1");
String encTrack2 = decodeData.get("encTrack2");
String encTrack3 = decodeData.get("encTrack3");
String track1Status = decodeData.get("track1Status");
String track2Status = decodeData.get("track2Status");
String track3Status = decodeData.get("track3Status");
String partialTrack = decodeData.get("partialTrack");
String productType = decodeData.get("productType");
String content = getString(R.string.card_swiped);
content += getString(R.string.format_id) + " " + formatID + "\n";
content += getString(R.string.masked_pan) + " " + maskedPAN + "\n";
content += getString(R.string.expiry_date) + " " + expiryDate + "\n";
content += getString(R.string.cardholder_name) + " " + cardHolderName + "\n";
content += getString(R.string.ksn) + " " + ksn + "\n";
content += getString(R.string.service_code) + " " + serviceCode + "\n";
content += getString(R.string.track_1_length) + " " + track1Length + "\n";
content += getString(R.string.track_2_length) + " " + track2Length + "\n";
content += getString(R.string.track_3_length) + " " + track3Length + "\n";
content += getString(R.string.encrypted_tracks) + " " + encTracks + "\n";
content += getString(R.string.encrypted_track_1) + " " + encTrack1 + "\n";
content += getString(R.string.encrypted_track_2) + " " + encTrack2 + "\n";
content += getString(R.string.encrypted_track_3) + " " + encTrack3 + "\n";
content += getString(R.string.track_1_status) + " " + track1Status + "\n";
content += getString(R.string.track_2_status) + " " + track2Status + "\n";
content += getString(R.string.track_3_status) + " " + track3Status + "\n";
content += getString(R.string.partial_track) + " " + partialTrack + "\n";
content += getString(R.string.product_type) + " " + productType + "\n";
statusEditText.setText(content);
if(serviceCode.endsWith("0") || serviceCode.endsWith("6"))
{
wisePadController.startPinEntry();
}
}
else if(checkCardResult == CheckCardResult.NO_RESPONSE)
{
statusEditText.setText(getString(R.string.card_no_response));
}
else if(checkCardResult == CheckCardResult.TRACK2_ONLY)
{
String formatID = decodeData.get("formatID");
String maskedPAN = decodeData.get("maskedPAN");
String expiryDate = decodeData.get("expiryDate");
String cardHolderName = decodeData.get("cardholderName");
String ksn = decodeData.get("ksn");
String serviceCode = decodeData.get("serviceCode");
String track1Length = decodeData.get("track1Length");
String track2Length = decodeData.get("track2Length");
String track3Length = decodeData.get("track3Length");
String encTracks = decodeData.get("encTracks");
String encTrack1 = decodeData.get("encTrack1");
String encTrack2 = decodeData.get("encTrack2");
String encTrack3 = decodeData.get("encTrack3");
String track1Status = decodeData.get("track1Status");
String track2Status = decodeData.get("track2Status");
String track3Status = decodeData.get("track3Status");
String partialTrack = decodeData.get("partialTrack");
String productType = decodeData.get("productType");
statusEditText.setText(content);
if(serviceCode.endsWith("0") || serviceCode.endsWith("6")) {
wisePadController.startPinEntry();
}
}
}
}
Gracias y espero que me puedan ayudar.