本文整理汇总了Java中android.media.MediaScannerConnection.connect方法的典型用法代码示例。如果您正苦于以下问题:Java MediaScannerConnection.connect方法的具体用法?Java MediaScannerConnection.connect怎么用?Java MediaScannerConnection.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.MediaScannerConnection
的用法示例。
在下文中一共展示了MediaScannerConnection.connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scanFile
import android.media.MediaScannerConnection; //导入方法依赖的package包/类
/**
* 扫描指定的文件
*
* @param context
* @param filePath
* @param sListener
*/
public static MediaScannerConnection scanFile(Context context, String[] filePath, String[] mineType,
MediaScannerConnection.OnScanCompletedListener sListener) {
ClientProxy client = new ClientProxy(filePath, mineType, sListener);
try {
MediaScannerConnection connection = new MediaScannerConnection(
context.getApplicationContext(), client);
client.mConnection = connection;
connection.connect();
return connection;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例2: sendVideo
import android.media.MediaScannerConnection; //导入方法依赖的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();
}
示例3: onCreate
import android.media.MediaScannerConnection; //导入方法依赖的package包/类
@Override
public void onCreate()
{
super.onCreate();
if (!mCommunicationServer.start() || !mSeamlessServer.start())
stopSelf();
mNotificationUtils = new NotificationUtils(this);
mDatabase = new AccessDatabase(this);
mMediaScanner = new MediaScannerConnection(this, null);
mHotspotUtils = HotspotUtils.getInstance(this);
mWifiLock = ((WifiManager) getApplicationContext().getSystemService(Service.WIFI_SERVICE))
.createWifiLock(TAG);
mReceive.setNotifyDelay(2000);
mSend.setNotifyDelay(2000);
mMediaScanner.connect();
getWifiLock().acquire();
updateServiceState(getNotificationUtils().getPreferences().getBoolean("trust_always", false));
}
示例4: connectMediaScan
import android.media.MediaScannerConnection; //导入方法依赖的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();
}
示例5: SimpleMediaScannerConnction
import android.media.MediaScannerConnection; //导入方法依赖的package包/类
public SimpleMediaScannerConnction(final Context context, final File f) {
fileToScan = f;
mediaScannerConnection = new MediaScannerConnection(context, this);
try {
mediaScannerConnection.connect();
} catch (final Exception e) {
e.printStackTrace();
}
}
示例6: saveImageSendScanner
import android.media.MediaScannerConnection; //导入方法依赖的package包/类
/**
* 保存后用MediaScanner扫描,通用的方法
*
*/
private static void saveImageSendScanner (Context context, MyMediaScannerConnectionClient scannerClient) {
final MediaScannerConnection scanner = new MediaScannerConnection(context, scannerClient);
scannerClient.setScanner(scanner);
scanner.connect();
}
示例7: onActivityCreated
import android.media.MediaScannerConnection; //导入方法依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
mMediaScanner = new MediaScannerConnection(getActivity(), null);
mMediaScanner.connect();
mIntentFilter.addAction(ACTION_FILE_LIST_CHANGED);
if (getAdapter().getPath() == null)
goPath(FileUtils.getApplicationDirectory(getActivity()));
}
示例8: saveImageSendScanner
import android.media.MediaScannerConnection; //导入方法依赖的package包/类
/**
* 保存后用MediaScanner扫描,通用的方法
*
*/
public static void saveImageSendScanner (Activity activity, MyMediaScannerConnectionClient scannerClient) {
final MediaScannerConnection scanner = new MediaScannerConnection(activity, scannerClient);
scannerClient.setScanner(scanner);
scanner.connect();
}
示例9: connectMediaScan
import android.media.MediaScannerConnection; //导入方法依赖的package包/类
private void connectMediaScan(final String filename) {
msc = new MediaScannerConnection(mActivity, new MediaScannerConnection.MediaScannerConnectionClient() {
@Override
public void onScanCompleted(String path, Uri uri) {
msc.disconnect();
}
@Override
public void onMediaScannerConnected() {
msc.scanFile(filename, "image/png");
}
});
msc.connect();
}
示例10: loadFinish
import android.media.MediaScannerConnection; //导入方法依赖的package包/类
@Override
public void loadFinish(Object obj) {
Bundle bundle = (Bundle) obj;
boolean isSmallPic = bundle.getBoolean(DATA_IS_SIAMLL_PIC);
String filePath = bundle.getString(DATA_FILE_PATH);
File newFile = new File(filePath);
JDMediaScannerConnectionClient connectionClient = new JDMediaScannerConnectionClient(isSmallPic,
newFile);
connection = new MediaScannerConnection(getActivity(), connectionClient);
connectionClient.setMediaScannerConnection(connection);
connection.connect();
}
示例11: loadFinish
import android.media.MediaScannerConnection; //导入方法依赖的package包/类
@Override
public void loadFinish(Object obj) {
//下载完图片后,通知更新
Bundle bundle = (Bundle) obj;
boolean isSmallPic = bundle.getBoolean(DATA_IS_SIAMLL_PIC);
String filePath = bundle.getString(DATA_FILE_PATH);
File newFile = new File(filePath);
JDMediaScannerConnectionClient connectionClient = new JDMediaScannerConnectionClient(isSmallPic,
newFile);
connection = new MediaScannerConnection(this, connectionClient);
connectionClient.setMediaScannerConnection(connection);
connection.connect();
}
示例12: MediaScannerNotifier
import android.media.MediaScannerConnection; //导入方法依赖的package包/类
public MediaScannerNotifier(Context context, File file) {
mFile = file;
mConnection = new MediaScannerConnection(context, this);
mConnection.connect();
mContext = context;
}
示例13: scanPhoto
import android.media.MediaScannerConnection; //导入方法依赖的package包/类
public static void scanPhoto(final String imageFileName) {
msConn = new MediaScannerConnection(MyApplication.getInstance(), new MediaScannerConnection.MediaScannerConnectionClient() {
public void onMediaScannerConnected() {
msConn.scanFile(imageFileName, null);
Log.i("msClient objy", "connection established");
}
public void onScanCompleted(String path, Uri uri) {
msConn.disconnect();
Log.i("msClient Utility", "scan completed");
}
});
msConn.connect();
}
示例14: loadPictureIntoGalleryApp
import android.media.MediaScannerConnection; //导入方法依赖的package包/类
private void loadPictureIntoGalleryApp(final String filename) {
MoPubMediaScannerConnectionClient mediaScannerConnectionClient =
new MoPubMediaScannerConnectionClient(filename, null);
final MediaScannerConnection mediaScannerConnection =
new MediaScannerConnection(mContext, mediaScannerConnectionClient);
mediaScannerConnectionClient.setMediaScannerConnection(mediaScannerConnection);
mediaScannerConnection.connect();
}
示例15: MediaScannerNotifier
import android.media.MediaScannerConnection; //导入方法依赖的package包/类
public MediaScannerNotifier(Context context, String path) {
this.path = path;
connection = new MediaScannerConnection(context, this);
connection.connect();
}