本文整理匯總了Java中android.media.MediaScannerConnection.MediaScannerConnectionClient類的典型用法代碼示例。如果您正苦於以下問題:Java MediaScannerConnectionClient類的具體用法?Java MediaScannerConnectionClient怎麽用?Java MediaScannerConnectionClient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MediaScannerConnectionClient類屬於android.media.MediaScannerConnection包,在下文中一共展示了MediaScannerConnectionClient類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sendVideo
import android.media.MediaScannerConnection.MediaScannerConnectionClient; //導入依賴的package包/類
public void sendVideo(View view) {
if (TextUtils.isEmpty(localPath)) {
EMLog.e("Recorder", "recorder fail please try again!");
return;
}
msc = new MediaScannerConnection(this,
new MediaScannerConnectionClient() {
@Override
public void onScanCompleted(String path, Uri uri) {
Log.d("log scanner completed");
msc.disconnect();
setResult(RESULT_OK, getIntent().putExtra("uri", uri));
finish();
}
@Override
public void onMediaScannerConnected() {
msc.scanFile(localPath, "video/*");
}
});
msc.connect();
}
示例2: connectMediaScan
import android.media.MediaScannerConnection.MediaScannerConnectionClient; //導入依賴的package包/類
private void connectMediaScan(final String filename) {
msc = new MediaScannerConnection(this, new MediaScannerConnectionClient() {
@Override
public void onScanCompleted(String path, Uri uri) {
savedUri = uri;
msc.disconnect();
if (isNeedShare) {
KakaoShare.shareImageKakao(MainImageActivity.this, uri);
}
isNeedShare = false;
}
@Override
public void onMediaScannerConnected() {
msc.scanFile(filename, "image/png");
}
});
msc.connect();
}
示例3: scanPhoto
import android.media.MediaScannerConnection.MediaScannerConnectionClient; //導入依賴的package包/類
public void scanPhoto(final String imageFileName)
{
msConn = new MediaScannerConnection(PreviewDemo.this,new MediaScannerConnectionClient()
{
public void onMediaScannerConnected()
{
msConn.scanFile(imageFileName, null);
Log.i("msClient obj in Photo Utility","connection established");
}
public void onScanCompleted(String path, Uri uri)
{
msConn.disconnect();
Log.i("msClient obj in Photo Utility","scan completed");
}
});
msConn.connect();
}
示例4: saveImage
import android.media.MediaScannerConnection.MediaScannerConnectionClient; //導入依賴的package包/類
private void saveImage(Bitmap image, String fileName)
{
File direct = new File(path);
if(!direct.exists())
{
direct.mkdirs();
}
File file = new File(new File(path), fileName);
if(file.exists())
file.delete();
try
{
FileOutputStream out = new FileOutputStream(file);
image.compress(Bitmap.CompressFormat.PNG, 100, out);
out.flush();
out.close();
Toast.makeText(this, fileName+" is saved at "+path, 2000)
.show();
// update after the media scanner after saving
MediaScannerConnectionClient client = new MyMediaScannerConnectionClient(getApplicationContext(), file, null);
}catch(Exception e)
{
e.printStackTrace();
}
}