Android MediaScannerConnection - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android MediaScannerConnection class.

This code example shows how to use the following methods:connect
    private File mFile;
    private Context mContext;
 
    public MediaScannerNotifier(Context context, File file) {
        mFile = file;
        mConnection = new MediaScannerConnection(context, this);
        mConnection.connect();
        mContext = context;
 
    } 
 
    public void onMediaScannerConnected() { 
        mConnection.scanFile(mFile.getAbsolutePath(), null);
    } 
 
    public void onScanCompleted(String path, Uri uri) {
        try { 
            if (uri != null) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(uri);
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:connect
    private MediaScannerConnection mConnection;
    private String mPath;
 
    private FFMpegMediaScannerNotifier(Context context, String path) {
        mPath = path;
        mConnection = new MediaScannerConnection(context, this);
        mConnection.connect();
    } 
     
    public static void scan(Context context, String path) {
    	new FFMpegMediaScannerNotifier(context, path);
    } 
 
    public void onMediaScannerConnected() { 
        mConnection.scanFile(mPath, null);
    } 
 
    public void onScanCompleted(String path, Uri uri) {
        mConnection.disconnect();
    } 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:isConnected, scanFile
		conn = new MediaScannerConnection(context, this);
		conn.connect();
	} 
 
	public void scanFile(String path, String mime) {
		if (conn.isConnected())
			conn.scanFile(path, mime);
		else { 
			filePath = path;
			mimeType = mime;
		} 
	} 
 
	public void onMediaScannerConnected() { 
		if (filePath != null)
			conn.scanFile(filePath, mimeType);
 
		filePath = null;
		mimeType = null;
	} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:scanFile
            mPath = path;
        } 
 
        @Override 
        public void onMediaScannerConnected() { 
            mScannerConnection.scanFile(mPath, null);
        } 
 
        @Override 
        public void onScanCompleted(String path, Uri uri) {
            mScannerConnection.disconnect();
 
            // try to start an activity to view the file 
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            try { 
                mContext.startActivity(intent);
            } catch (ActivityNotFoundException e) {
                Toast.makeText(mContext, R.string.start_activity_failed_message,
                        Toast.LENGTH_SHORT).show();
            } 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:connect
    private MediaScannerConnection mMs;
    private File mFile;
 
    public SingleMediaScanner(Context context, File f) {
        this.mFile = f;
        this.mMs = new MediaScannerConnection(context, this);
        this.mMs.connect();
    } 
 
    @Override 
    public void onMediaScannerConnected() { 
        this.mMs.scanFile(this.mFile.getAbsolutePath(), null);
    } 
 
    @Override 
    public void onScanCompleted(String path, Uri uri) {
        this.mMs.disconnect();
    } 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:connect
    private Context mContext;
 
    public MediaScannerNotifier(Context context, File file)
    { 
        mFile = file;
        mConnection = new MediaScannerConnection(context, this);
        mConnection.connect();
        mContext = context;
 
    } 
 
    public void onMediaScannerConnected() 
    { 
        mConnection.scanFile(mFile.getAbsolutePath(), null);
    } 
 
    public void onScanCompleted(String path, Uri uri)
    { 
        try 
        { 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:connect
	private MediaScannerConnection mMs;
	private File mFile;
 
	public MediaScannerNotifier(Context context, File f) {
	    mFile = f;
	    mMs = new MediaScannerConnection(context, this);
	    mMs.connect();
	} 
 
	@Override 
	public void onMediaScannerConnected() { 
	    mMs.scanFile(mFile.getAbsolutePath(), null);
	} 
 
	@Override 
	public void onScanCompleted(String path, Uri uri) {
	    mMs.disconnect();
	} 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:disconnect
    } 
 
    MediaScannerConnection.MediaScannerConnectionClient mMediaScannerConnectionClient = new MediaScannerConnection.MediaScannerConnectionClient() {
        public void onScanCompleted(String path, Uri uri) { 
            Log.d(TAG, "Scan of " + path + " completed -> uri " + uri); 
            mConnection.disconnect(); 
            finish(); 
        } 
        public void onMediaScannerConnected() { 
            Log.d(TAG, "Connected to media scanner, scanning " + mScreenshotFile); 
            mConnection.scanFile(mScreenshotFile, null); 
        } 
    }; 
 
    void takeScreenshot(final int delay) {
        mHander.postDelayed(new Runnable() {
            @Override 
            public void run() { 
                takeScreenshot(); 
            } 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:connect
	public void scanImage(String path) 
	{  
		this.path = path;
		 
	    if(conn!=null) conn.disconnect();  
	    conn = new MediaScannerConnection(context, this); 
	    conn.connect(); 
	} 
 
	public void onMediaScannerConnected() {  
	    try{ 
	    	Log.i("REC Photo Editor","Start Media Scanner");
	        conn.scanFile(path, "image/*");
	       } catch (java.lang.IllegalStateException e){
	       } 
	} 
 
	public void onScanCompleted(String path, Uri uri) { 
	    conn.disconnect(); 
	}  
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:connect, disconnect, isConnected
	/** 
	 * 미디어 프로바이터에 등록하여 음악 플레이어가 인식 할수 있도록 한다. 
	 */ 
	private void registerAudio() { 
		// 미디어 커낵션이 연결되어 있으면 연결 종료후 다시 연결 
		if(mMediaConnection.isConnected()){
			mMediaConnection.disconnect();
		} 
		mMediaConnection.connect();
	} 
 
	/** 
	 * MediaRecorder 초기화 하기 
	 */ 
	private void initRecorder(){ 
		//	중복파일이 되지 않도록 현재 시간을 파일명으로 설정한다. 
		Calendar cal = Calendar.getInstance();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmm");
		fileName = sdf.format(cal.getTime());
		// 파일경로및 파일명 설정 
5
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Android MediaScannerConnection Questions & Answers:

See Code Examples for Android MediaScannerConnection Methods: