USB MTP - exported files not visible

Started by hgmichna, August 07, 2014, 10:51:09

0 Members and 1 Guest are viewing this topic.

hgmichna

When the phone is connected to a computer via USB, using MTP, the exported files are not visible before the phone is rebooted. Solution from

https://code.google.com/p/android/issues/detail?id=38282

When writing files that should be accessible via USB MTP by the user:

For each file:

sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(file)));

Otherwise the files remain invisible.

Current workarounds are to reboot the phone or to rename the export folder using ES File Manager and, if that is not enough, disconnecting and reconnecting the phone. There may be other workarounds.
  •  

Mek

Yes, this is very annoying. I have to use FTP server over wifi as a workaround.
Do you like Scrabble? You can play on SKREBL.EU (my personal project) - free, various language versions available!
  •  

Menion

it's well know (and really stupid) issue in Android probably since version 4.0 and still not yet fixed ...

https://code.google.com/p/android/issues/detail?id=38282
- Official help (ideas, questions, problems): help.locusmap.eu
- Advanced topics, sharing of knowledges: you're here!
- LM 4 Beta download, LM 4 Release download
  •  

hgmichna

But what do you think about this post from the discussion you mentioned above?

----- Quote begins -----
#105 fatih.fd...@gmail.com

I have written a small app. The files created by my app is not visible on PC. But if I use this code " sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(file)));" foreach file. The files are visible. I think there is no bug. The problem is developers who not use fully the Android enviroment.

I have tries a couple File Explorer, and ES File Explorer is working good. The changes it cause is immediately applied to PC.
Stock apps (camera,contacts) are also working well. New photos, deleted photos, the export file of contacts is immediatly applied to PC.

So the problem is not Android. The problem is developers who not uses the Android enviroment properly.


Android developers may add this process to the .createNewFile, .delete, etc. methods. But maybe there is something which we don't know why theye don't add.

Thus, if an app which creates (copies) , moves (renames), and deletes files-directories, has this problem, tell it to the developer of the app. They should use some code like a sent above.
----- Quote ends -----
  •