List of usage examples for android.content Intent ACTION_MEDIA_SCANNER_SCAN_FILE
String ACTION_MEDIA_SCANNER_SCAN_FILE
To view the source code for android.content Intent ACTION_MEDIA_SCANNER_SCAN_FILE.
Click Source Link
From source file:org.anothermonitor.ServiceReader.java
void stopRecord() { recording = false;/*from w ww . j a v a 2s .c om*/ sendBroadcast(new Intent(C.actionSetIconRecord)); try { mW.flush(); mW.close(); mW = null; // http://stackoverflow.com/questions/13737261/nexus-4-not-showing-files-via-mtp // MediaScannerConnection.scanFile(this, new String[] { mFile.getAbsolutePath() }, null, null); // http://stackoverflow.com/questions/5739140/mediascannerconnection-produces-android-app-serviceconnectionleaked sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE).setData(Uri.fromFile(mFile))); Toast.makeText(this, new StringBuilder().append(getString(R.string.app_name)).append("Record-").append(getDate()) .append(".csv ").append(getString(R.string.notify_toast_saved)), Toast.LENGTH_LONG).show(); } catch (Exception e) { e.printStackTrace(); Toast.makeText(this, getString(R.string.notify_toast_error) + " " + e.getMessage(), Toast.LENGTH_LONG) .show(); } topRow = true; mNM.notify(10, mNotificationRead); }
From source file:de.baumann.hhsmoodle.fragmentsMain.FragmentBrowser.java
private void screenshot() { shareFile = helper_main.newFile();/*from w ww .ja v a 2s. co m*/ try { mWebView.measure( View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); mWebView.layout(0, 0, mWebView.getMeasuredWidth(), mWebView.getMeasuredHeight()); mWebView.setDrawingCacheEnabled(true); mWebView.buildDrawingCache(); bitmap = Bitmap.createBitmap(mWebView.getMeasuredWidth(), mWebView.getMeasuredHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); int iHeight = bitmap.getHeight(); canvas.drawBitmap(bitmap, 0, iHeight, paint); mWebView.draw(canvas); } catch (OutOfMemoryError e) { e.printStackTrace(); Snackbar.make(mWebView, R.string.toast_screenshot_failed, Snackbar.LENGTH_SHORT).show(); } if (bitmap != null) { try { OutputStream fOut; fOut = new FileOutputStream(shareFile); bitmap.compress(Bitmap.CompressFormat.PNG, 50, fOut); fOut.flush(); fOut.close(); bitmap.recycle(); Snackbar.make(mWebView, getString(R.string.context_saveImage_toast) + " " + helper_main.newFileName(), Snackbar.LENGTH_SHORT).show(); Uri uri = Uri.fromFile(shareFile); Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri); getActivity().sendBroadcast(intent); } catch (Exception e) { e.printStackTrace(); Snackbar.make(mWebView, R.string.toast_perm, Snackbar.LENGTH_SHORT).show(); } } }
From source file:org.creativecommons.thelist.misc.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case PhotoConstants.PICK_PHOTO_REQUEST: case PhotoConstants.TAKE_PHOTO_REQUEST: if (resultCode == RESULT_OK) { //photoToBeUploaded = true; mItemToBeUploaded = mCurrentItem; uploadItemPosition = activeItemPosition; if (data == null) { //Toast.makeText(this,getString(R.string.general_error),Toast.LENGTH_LONG).show(); Log.d(TAG, "> onActivityResult > data == null"); } else { mMediaUri = data.getData(); }//ww w . j ava 2s . c o m Log.i(TAG, "Media URI:" + mMediaUri); //TODO: make sure for sure auth will exist for this to happen //Add photo to the Gallery (listen for broadcast and let gallery take action) Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); mediaScanIntent.setData(mMediaUri); sendBroadcast(mediaScanIntent); startPhotoUpload(); } //RESULT OK else if (resultCode != RESULT_CANCELED) { //result other than ok or cancelled //Toast.makeText(this, R.string.general_error, Toast.LENGTH_SHORT).show(); Log.d(TAG, "> onActivityResult > resultCode != canceled"); } break; } //switch }
From source file:com.ezac.gliderlogs.FlightOverviewActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_insert: if (!app_hld) { createNewFlight();//from ww w .java 2s . c o m } else { makeToast("Er is een te groot verschil in tijd tussen de tablet en de " + "\nwerkelijke tijd gevonden, verschil is thans " + timedrift + " sec.," + "\nu MOET eerst middels :" + "\nInstellingen -> Datum en Tijd -> de datum en tijd GOED instellen." + "\nVoer daarna de optie \"Dag opstarten\" opnieuw uit." + "\nDit MOET worden gedaan binnen een active WiFi netwerk" + "\nvoordat de applicatie MAG worden gebruikt", 1); } return true; case R.id.action_service: DoServices(); return true; case R.id.action_db_start: DoAction(1, "Weet u zeker dat u een nieuwe vliegdag wilt starten ??"); return true; case R.id.action_db_close: DoAction(2, "Wilt u een overzicht van de huidige dag ??"); return true; case R.id.action_db_pass: DoAction(3, "Wilt u de passagiers lijst verversen ??"); return true; case R.id.action_settings: DoSettings(); return true; case R.id.action_ready: OptionSelect(R.id.action_ready, R.id.action_open, R.id.action_45min, R.id.action_my, R.id.action_all); DoFlightFilter(1, ""); return true; case R.id.action_open: OptionSelect(R.id.action_open, R.id.action_ready, R.id.action_45min, R.id.action_my, R.id.action_all); DoFlightFilter(2, ""); return true; case R.id.action_pass: createPassengerOverview(); return true; case R.id.action_leden: createMemberOverview(); return true; case R.id.action_resv: createReservationOverview(); return true; case R.id.action_duty: createOnDutyOverview(); return true; case R.id.action_meteo_1: createWeather1_Overview(); return true; case R.id.action_meteo_2: createWeather2_Overview(); return true; case R.id.action_45min: OptionSelect(R.id.action_45min, R.id.action_open, R.id.action_ready, R.id.action_my, R.id.action_all); DoFlightFilter(3, ""); return true; case R.id.action_my: DoFlightMember(); return true; case R.id.action_all: OptionSelect(R.id.action_all, R.id.action_open, R.id.action_ready, R.id.action_45min, R.id.action_my); DoFlightFilter(4, ""); return true; case R.id.action_ogn_flarm: createOGNOverview(); return true; case R.id.action_adsb: createGliderOverview(); return true; case R.id.action_adsb_lcl: createADSBOverview(); return true; case R.id.action_ntm_nld: createNotamNLDOverview(); return true; case R.id.action_ntm_blx: createNotamBLXOverview(); return true; case R.id.action_ezac: createEzacOverview(); return true; case R.id.action_net: makeToast("Blauwe wereld bol = host ping test ok,\n" + "Grijze wereld bol = geen internet/server verbinding\n" + "Groen icon = synchronisatie data naar host server = ok\n" + "Rood icon = fout bij applicatie synchronisatie naar host\n" + "Laatste synchronisatie status = " + (sync_sts.equals("") ? "ok" : sync_sts), 0); return true; case R.id.action_db_export_CSV: GliderLogToCSV("gliderlogs.db", "ezac"); GliderLogToDB("com.ezac.gliderlogs", "gliderlogs.db", "ezac"); sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + Environment.getExternalStorageDirectory()))); makeToast("Export naar een CSV bestand is uitgevoerd !", 2); return true; case R.id.action_about: DoInfo(); return true; } return super.onOptionsItemSelected(item); }
From source file:kr.ac.kpu.wheeling.blackbox.Camera2VideoFragment.java
public void startMediaScanning(Context context, String fileName) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { final Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + getVideoStorageDir("wheeling") + "/" + fileName)); //final Intent scanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); //final Uri contentUri = Uri.fromFile(file); //scanIntent.setData(contentUri); context.sendBroadcast(intent);// w w w . j ava 2 s . co m Log.d("BROADCAST", "Broadcast Complete!"); } else { final Intent intent = new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())); context.sendBroadcast(intent); Log.d("BROADCAST", "Broadcast Complete!(Low ver)"); } }
From source file:com.ereinecke.eatsafe.MainActivity.java
/** * Sends a broadcast to have the media scanner scan a file * * @param path//from w ww .j a va 2s. co m * the file to scan */ private void scanMedia(String path) { File file = new File(path); Uri uri = Uri.fromFile(file); Intent scanFileIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri); sendBroadcast(scanFileIntent); }
From source file:es.upv.riromu.arbre.main.MainActivity.java
private void galleryAddPic() { Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, image_uri); sendBroadcast(mediaScanIntent); }
From source file:com.channelsoft.common.bitmapUtil.ImageWorker.java
public static void scanFileAsync(Context ctx, String filePath) { LogUtil.begin("filePath:" + filePath); Intent scanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); scanIntent.setData(Uri.fromFile(new File(filePath))); ctx.sendBroadcast(scanIntent);/*from w w w. j a va2 s. c o m*/ }
From source file:org.creativecommons.thelist.fragments.MyListFragment.java
public void prepForPhotoUpload(Intent data) { mItemToBeUploaded = mCurrentItem;/*from w ww . ja va2 s . com*/ uploadItemPosition = activeItemPosition; if (data == null) { //Toast.makeText(this,getString(R.string.general_error),Toast.LENGTH_LONG).show(); Log.d(TAG, "> onActivityResult > data == null"); } else { mMediaUri = data.getData(); } Log.v(TAG, "Media URI:" + mMediaUri); //Add photo to the Gallery (listen for broadcast and let gallery take action) final Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); mediaScanIntent.setData(mMediaUri); getActivity().sendBroadcast(mediaScanIntent); }
From source file:com.almalence.opencam.SavingService.java
public static void broadcastNewPicture(Uri uri) { if (ApplicationScreen.instance != null) { ApplicationScreen.instance.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri)); ApplicationScreen.getMainContext() .sendBroadcast(new Intent("android.hardware.action.NEW_PICTURE", uri)); // Keep compatibility ApplicationScreen.getMainContext().sendBroadcast(new Intent("com.android.camera.NEW_PICTURE", uri)); }//w ww . j ava 2 s. com }