

Posted by EHXM. Posted in " 안드로이드/Tech Note "2010/06/10 23:12
수동으로 미디어 스캔을 하는 클래스입니다. 강제 Media Scan Sample Source
import android.content.Context;
import android.media.MediaScannerConnection;
import android.net.Uri;
public class MediaScanner {
private MediaScannerConnection mediaScanConn = null;
private MusicSannerClient client = null;
private String filePath = null;
private String fileType = null;
private String[] filePaths = null;
/**
* Then call the MediaScanner .scanFile("/sdcard/2.mp3");
* */
public MediaScanner(Context context) {
// Create MusicSannerClient
if (client == null) {
client = new MusicSannerClient();
}
if (mediaScanConn == null) {
mediaScanConn = new MediaScannerConnection(context, client);
}
}
class MusicSannerClient implements
MediaScannerConnection.MediaScannerConnectionClient {
public void onMediaScannerConnected() {
if(filePath != null){
mediaScanConn.scanFile(filePath, fileType);
}
if(filePaths != null){
for(String file: filePaths){
mediaScanConn.scanFile(file, fileType);
}
}
filePath = null;
fileType = null;
filePaths = null;
}
public void onScanCompleted(String path, Uri uri) {
// TODO Auto-generated method stub
mediaScanConn.disconnect();
}
}
/**
* Scan file label information
* @param filePath File path eg :/sdcard/MediaPlayer/dahai.mp3
* @param fileType File type eg : audio/mp3 media/* application/ogg
* */
public void scanFile(String filepath,String fileType) {
this.filePath = filepath;
this.fileType = fileType;
// After the connection has been called the onMediaScannerConnected MusicSannerClient () Method
mediaScanConn.connect();
}
/**
* @param filePaths File path
* @param fileType File types
* */
public void scanFile(String[] filePaths,String fileType){
this.filePaths = filePaths;
this.fileType = fileType;
mediaScanConn.connect();
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public String getFileType() {
return fileType;
}
public void setFileType(String fileType) {
this.fileType = fileType;
}
}
여러분의 커뮤니케이션을 기다리고 있습니다.

아이디어의 전쟁의 현장이었던 2010년 대한민국 매쉬업 경진대회에 다녀왔습니다. 이번 대회는 지난 2월 6일(토요일), 삼성동 코엑스 컨퍼런스룸 401에서 열렸습니다. 이번.....
2010년에 100가지가 넘는 안드로이드 폰 출시가 될 예정입니다. Mobile World Congress keynote에서 Google CEO Eric Schmidt의 연설.....
서울, 안양, 부산, 대구, 광주, 대전에 안드로이드 폰 체험 할 수 있는 곳이 있네요. 저는 코엑스 메가박스 입구에 있는 모토로라 체험 부스에서 우연히 모토로이를 만져보게 되.....
위 3D 갤러리는 http://www.fotoviewr.com/ 사이트의 Fotoviewr 입니다. Flex와 Papervision3D를 이용하여 위와같은 3D 갤러리를 구현해.....
Total : 115,867 Today : 223 Yesterday : 155