How to determine when a bluetooth file is received?

大城市里の小女人 提交于 2019-12-01 09:50:52

问题


In my app, I need to edit an bluetooth-transferred file just after it is received.

Exactly what Intent do I have to listen to with my BroadcastReceiver, in order to find out when a file has been received via Bluetooth?

Also, please tell me if there are other solutions.


回答1:


If the user gets a file via android OS, it's via the download manager. in that case u should register DownloadManager.ACTION_DOWNLOAD_COMPLETE

private void registerBroadcastReceiver() {
    broadCastReceiver = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
                //your code here
            }
        }
    };
    IntentFilter filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
    registerReceiver(broadCastReceiver, filter);

}


来源:https://stackoverflow.com/questions/18829373/how-to-determine-when-a-bluetooth-file-is-received

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