Skip to content Skip to sidebar Skip to footer

Bluetooth Printer Connection Failed In Android

I want to make a POS app. In this app, I need to print a receipt, but I have a problem with the bluetooth connection. In this code, I want to set the printer device that I use in m

Solution 1:

remove this line from fragment KeyListenerInit method because you already initialize object in Activity then why you again intialize this.

((MainActivity)getActivity()).setMService();

and remove this code from onCreate method because you already add this code in onStart method so no need in onCreate method:

if (!mBluetoothAdapter.isEnabled()) {
        IntentenableIntent=newIntent(
                BluetoothAdapter.ACTION_REQUEST_ENABLE);
        startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
        // Otherwise, setup the session
    } else {
        if (mService == null) {
            setMService();
        }
    }

Post a Comment for "Bluetooth Printer Connection Failed In Android"