java – Android Wear Channel API status code 8

بدون دیدگاه


I’m trying to send a file from the phone to the wear app, on the phone I’m sending the file as follows with a successful status.

NodeApi.GetConnectedNodesResult nodesResult = Wearable.NodeApi.getConnectedNodes(mGoogleApiClient).await();
for (Node node : nodesResult.getNodes()) {
      ChannelApi.OpenChannelResult result = Wearable.ChannelApi.openChannel(mGoogleApiClient, node.getId(), "/songs").await();
      Channel channel = result.getChannel();
File file = new File(AppUtils.getDownloadsDir(getApplicationContext()),"lift.mp3");
      Log.d(TAG, "call: " + file.canRead() + Uri.fromFile(file) + file.length());
      channel.sendFile(mGoogleApiClient, Uri.fromFile(file)).setResultCallback(
          new ResultCallback<Status>() {
            @Override
            public void onResult(@NonNull Status status) {
              Log.d(TAG, "onResult: " + status.isSuccess() + " " + status.getStatusMessage());
            }
          }
      );
      Log.d(TAG, "Node " + node.getId() + node.getDisplayName() + node.isNearby());
    }

On the wear side however, onChannelOpened is getting called with the correct path, I create a file, but when calling Channel.receiveFile I get a status code of 8 (INTERNAL_ERROR) in the resultCallback status.

public void onChannelOpened(final Channel channel) {
 if (channel.getPath().equals("/songs")) {

  try {
    final File outFile = prepareFile("wild.mp3");
    if (outFile == null || !outFile.exists()) {
      Log.d(TAG, "Failed to create file ");
      return;
    }
    Log.d(TAG, "onChannelOpened: " + mGoogleApiClient.isConnected());
    channel.receiveFile(mGoogleApiClient, Uri.fromFile(outFile), false).setResultCallback(
        new ResultCallback<Status>() {
          @Override
          public void onResult(@NonNull Status status) {
            int statusCode = status.getStatusCode();
            if (!status.isSuccess()) {
              Log.e(TAG, "receiveFile(): Failed to receive file with "
                  + "status code = " + statusCode
                  + ", and status: " + status.getStatus());
...



لینک منبع

برچسب‌ها:
  • نویسنده
    A-brand
  • تعداد بازدید
    4 views
0دیدگاه فرستاده شده است.
شما هم دیدگاه خود را بنویسید