安卓:文件,我写SD卡不能在Windows资源管理器中显示,宏碁Iconiatab [英] Android: Files that I write to the sdcard do not show in Windows explorer, for Acer Iconiatab

查看:256
本文介绍了安卓:文件,我写SD卡不能在Windows资源管理器中显示,宏碁Iconiatab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,创建文件,并写入到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(); 
            } 
        }

这篇关于安卓:文件,我写SD卡不能在Windows资源管理器中显示,宏碁Iconiatab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆