问题
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