Author Topic: USB MTP - exported files not visible  (Read 1175 times)

Offline hgmichna

  • More than Newbie
  • *
  • Posts: 13
    • View Profile
USB MTP - exported files not visible
« on: August 07, 2014, 10:51:09 »
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.
 

Offline Mek

  • More than Newbie
  • *
  • Posts: 82
    • View Profile
    • http://mekweb.eu/?lang=en
  • Device: SGS4Mini
Re: USB MTP - exported files not visible
« Reply #1 on: August 08, 2014, 21:38:02 »
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!
 

Offline menion

  • Administrator
  • Professor of Locus
  • *****
  • Posts: 11492
  • Thanked: 331 times
    • View Profile
    • http://www.asamm.com
  • Device: SGS7
Re: USB MTP - exported files not visible
« Reply #2 on: August 09, 2014, 18:24:34 »
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
Ideas, wishes, problems
Advanced topics, public discussion, sharing of knowledges, testing beta versions: you're here!
 

Offline hgmichna

  • More than Newbie
  • *
  • Posts: 13
    • View Profile
Re: USB MTP - exported files not visible
« Reply #3 on: August 27, 2014, 08:44:35 »
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 -----