How can I confim that a file was sent successfully via bluetooth using Android 4+

房东的猫 提交于 2019-12-01 08:13:17

Looking through the source, I see Constants.java and HandoverService.java which seem to indicate that a Broadcast is sent when the transfer is completed.

/** intent action used to indicate the completion of a handover transfer */
public static final String ACTION_BT_OPP_TRANSFER_DONE =
        "android.btopp.intent.action.BT_OPP_TRANSFER_DONE";

and

/** intent extra used to indicate the success of a handover transfer */
public static final String EXTRA_BT_OPP_TRANSFER_STATUS =
        "android.btopp.intent.extra.BT_OPP_TRANSFER_STATUS";

public static final int HANDOVER_TRANSFER_STATUS_SUCCESS = 0;
public static final int HANDOVER_TRANSFER_STATUS_FAILURE = 1;

In HandoverService:

if (action.equals(ACTION_BT_OPP_TRANSFER_DONE)) {
    int handoverStatus = intent.getIntExtra(EXTRA_BT_OPP_TRANSFER_STATUS,
            HANDOVER_TRANSFER_STATUS_FAILURE);
    if (handoverStatus == HANDOVER_TRANSFER_STATUS_SUCCESS) {

So basically, you need to register a BroadcastReceiver for ACTION_BT_OPP_TRANSFER_DONE, and then check for the EXTRA_BT_OPP_TRANSFER_STATUS extra and see if it was success or failure.

Since these don't appear to be part of the public API, be warned that this could change in a future release.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!