Samsung Accessory Protocol: Samsung Galaxy S4 and Samsung Gear S2 Connect Network Failure

Samsung Accessory Protocol: Samsung Galaxy S4 and Samsung Gear S2 Connect Network Failure

BY 12 Jul 2016 Web Application Development

Hello,

Trying to connect a consumer app (Android) and provider app (tizen) with Samsung Accessory Protocol.

When I load android app from Android Studio, it works well, but when if I turn off Samsung Galaxy S4, and I turn on, 

I receive a error 1280 (CONNECTION FAILURE NETWORK)

08-11 01:20:06.293 7993-8064/com.worldline.smartretail I/SASocket: Connection request enqued successfully for peer:39905
08-11 01:20:06.353 7993-8064/com.worldline.smartretail W/SASocket: connectionId is null so cleaning up
08-11 01:20:06.353 7993-8064/com.worldline.smartretail E/SAAgent: Connection attempt failed wih peer:39905 reason:1280
 
My Android Manifest.xml:
<receiver android:name="com.samsung.android.sdk.accessory.RegisterUponInstallReceiver">
    <intent-filter>
        <action android:name="com.samsung.accessory.action.REGISTER_AGENT" />
    </intent-filter>
</receiver>
<receiver android:name="com.samsung.android.sdk.accessory.ServiceConnectionIndicationBroadcastReceiver">
    <intent-filter>
        <action android:name="com.samsung.accessory.action.SERVICE_CONNECTION_REQUESTED" />
    </intent-filter>
</receiver>

My method for receive ServiceConnectionResponse:

@Override
protected void onServiceConnectionResponse(SAPeerAgent peerAgent, SASocket socket, int result) {
    if (result == SAAgent.CONNECTION_SUCCESS) {
        this.mConnectionHandler = (ServiceConnection) socket;
        smartwatchPresenter.onServiceConnectionEstablished();
        updateTextView("Connected");
    } else if (result == SAAgent.CONNECTION_ALREADY_EXIST) {
        updateTextView("Connected");
        Toast.makeText(getBaseContext(), "CONNECTION_ALREADY_EXIST", Toast.LENGTH_LONG).show();
    } else if (result == SAAgent.CONNECTION_DUPLICATE_REQUEST) {
        Toast.makeText(getBaseContext(), "CONNECTION_DUPLICATE_REQUEST", Toast.LENGTH_LONG).show();
    } else {
        Toast.makeText(getBaseContext(), "Service Connection Failure " + String.valueOf(result), Toast.LENGTH_LONG).show();
    }
}

Why connection works only when app is loaded from Android Studio? Only thing I see is that when Ioad app from Android Studio, I’m reinstalling the APK.

I’m using protocol TRANSPORT_BT.

Thank you,

Joaquim Puyo

Written by