安卓:文件,我写SD卡不能在Windows资源管理器中显示,宏碁Iconiatab能在、我写、宏碁、资源管理

由网友(〆柠檬心、薄荷情)分享简介:在我的应用程序,创建文件,并写入到SD卡。我创建的文件显示正确的DDMS,并在Windows资源管理器中,当我安装我的三星银河为USB设备。但是,他们不会在Windows资源管理器在我的宏碁ICONIA TAB A500表明,当通过USB连接。我认为这是由于在3.0差一些?我需要不同的创建我的文件在3.0,以便它们显示...

在我的应用程序,创建文件,并写入到SD卡。我创建的文件显示正确的DDMS,并在Windows资源管理器中,当我安装我的三星银河为USB设备。但是,他们不会在Windows资源管理器在我的宏碁ICONIA TAB A500表明,当通过USB连接。我认为这是由于在3.0差一些?我需要不同的创建我的文件在3.0,以便它们显示在Windows中使用USB?

In my application, I create files and write them to the Sdcard. My created files show properly in DDMS, and in windows explorer when I mount my Samsung Galaxy as a USB device. But, they do not show in Windows explorer on my Acer Iconia Tab A500, when it is connected by USB. I assume this is due to some difference in 3.0? Do I need to create my files differently in 3.0 so that they show in Windows by usb?

推荐答案

写入文件后,发送此意图解决的问题。幸得下议院的家伙,他所提供的答案在另一个论坛。

Sending this intent after writing the file solved the issue. Credit goes to Commons Guy, he provided the answer on another forum.

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"
            + Environment.getExternalStorageDirectory()))); 

编辑:共享盖伊也评论说,发送假冒的意图(如上)可能是一个坏主意,所以我用这个来代替:

Commons Guy did comment that sending a fake intent (like above) is probably a bad idea, so I used this instead:

   //called after writing file, from my activity 
    new SingleMediaScanner(this, path); 

    private class SingleMediaScanner implements MediaScannerConnectionClient 
    { 
            private MediaScannerConnection mMs; 
            private String path; 
            SingleMediaScanner(Context context, String f) 
            { 
                mPath = f; 
                mMs = new MediaScannerConnection(context, this); 
                mMs.connect(); 
            } 
            @Override 
            public void onMediaScannerConnected() 
            { 
                mMs.scanFile(mFile, null); 
            } 
            @Override 
            public void onScanCompleted(String path, Uri uri) 
            { 
                mMs.disconnect(); 
            } 
        }
阅读全文

相关推荐

最新文章