List of usage examples for android.os Environment DIRECTORY_NOTIFICATIONS
String DIRECTORY_NOTIFICATIONS
To view the source code for android.os Environment DIRECTORY_NOTIFICATIONS.
Click Source Link
From source file:com.irccloud.android.IRCCloudApplicationBase.java
@Override public void onCreate() { super.onCreate(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) TrustKit.initializeWithNetworkSecurityConfiguration(getApplicationContext(), R.xml.network_security_config); Fabric.with(this, new Crashlytics()); Crashlytics.log(Log.INFO, "IRCCloud", "Crashlytics Initialized"); FlowManager.init(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); if (Build.VERSION.SDK_INT >= 19) EmojiCompat.init(// ww w .ja v a 2s . c om new BundledEmojiCompatConfig(this).setReplaceAll(!prefs.getBoolean("preferSystemEmoji", true))); /*EmojiCompat.init(new FontRequestEmojiCompatConfig(getApplicationContext(), new FontRequest( "com.google.android.gms.fonts", "com.google.android.gms", "Noto Color Emoji Compat", R.array.com_google_android_gms_fonts_certs)) .setReplaceAll(!prefs.getBoolean("preferSystemEmoji", true)) .registerInitCallback(new EmojiCompat.InitCallback() { @Override public void onInitialized() { super.onInitialized(); EventsList.getInstance().clearCaches(); conn.notifyHandlers(NetworkConnection.EVENT_FONT_DOWNLOADED, null); } }));*/ NetworkConnection.getInstance().registerForConnectivity(); //Disable HTTP keep-alive for our app, as some versions of Android will return an empty response System.setProperty("http.keepAlive", "false"); //Allocate all the shared objects at launch conn = NetworkConnection.getInstance(); ColorFormatter.init(); if (prefs.contains("notify")) { SharedPreferences.Editor editor = prefs.edit(); editor.putString("notify_type", prefs.getBoolean("notify", true) ? "1" : "0"); editor.remove("notify"); editor.commit(); } if (prefs.contains("notify_sound")) { SharedPreferences.Editor editor = prefs.edit(); if (!prefs.getBoolean("notify_sound", true)) editor.putString("notify_ringtone", ""); editor.remove("notify_sound"); editor.commit(); } if (prefs.contains("notify_lights")) { SharedPreferences.Editor editor = prefs.edit(); if (!prefs.getBoolean("notify_lights", true)) editor.putString("notify_led_color", "0"); editor.remove("notify_lights"); editor.commit(); } if (!prefs.getBoolean("ringtone_migrated", false)) { if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { String notification_uri = prefs.getString("notify_ringtone", ""); if (notification_uri.startsWith("content://media/external/audio/media/")) { Cursor c = getContentResolver().query(Uri.parse(notification_uri), new String[] { MediaStore.Audio.Media.TITLE }, null, null, null); if (c != null && c.moveToFirst()) { if (c.getString(0).equals("IRCCloud")) { Log.d("IRCCloud", "Migrating notification ringtone setting: " + notification_uri); SharedPreferences.Editor editor = prefs.edit(); editor.remove("notify_ringtone"); editor.commit(); } } if (c != null && !c.isClosed()) { c.close(); } } File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_NOTIFICATIONS); File file = new File(path, "IRCCloud.mp3"); if (file.exists()) { file.delete(); } try { getContentResolver().delete(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, MediaStore.Audio.Media.TITLE + " = 'IRCCloud'", null); } catch (Exception e) { // Ringtone not in media DB } } try { String notification_uri = prefs.getString("notify_ringtone", ""); if (notification_uri.startsWith("content://media/")) { Cursor c = getContentResolver().query(Uri.parse(notification_uri), new String[] { MediaStore.Audio.Media.TITLE }, null, null, null); if (c != null && c.moveToFirst()) { if (c.getString(0).equals("IRCCloud")) { Log.d("IRCCloud", "Migrating notification ringtone setting: " + notification_uri); SharedPreferences.Editor editor = prefs.edit(); editor.remove("notify_ringtone"); editor.commit(); } } if (c != null && !c.isClosed()) { c.close(); } } } catch (Exception e) { //We might not have permission to query the media DB } try { getContentResolver().delete(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, MediaStore.Audio.Media.TITLE + " = 'IRCCloud'", null); } catch (Exception e) { // Ringtone not in media DB e.printStackTrace(); } File file = new File(getFilesDir(), "IRCCloud.mp3"); if (file.exists()) { file.delete(); } SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean("ringtone_migrated", true); editor.commit(); } if (prefs.contains("notify_pebble")) { try { int pebbleVersion = getPackageManager().getPackageInfo("com.getpebble.android", 0).versionCode; if (pebbleVersion >= 553 && Build.VERSION.SDK_INT >= 18) { SharedPreferences.Editor editor = prefs.edit(); editor.remove("notify_pebble"); editor.commit(); } } catch (Exception e) { } } if (prefs.contains("acra.enable")) { SharedPreferences.Editor editor = prefs.edit(); editor.remove("acra.enable"); editor.commit(); } if (prefs.contains("notifications_json")) { SharedPreferences.Editor editor = prefs.edit(); editor.remove("notifications_json"); editor.remove("networks_json"); editor.remove("lastseeneids_json"); editor.remove("dismissedeids_json"); editor.commit(); } prefs = getSharedPreferences("prefs", 0); if (prefs.getString("host", "www.irccloud.com").equals("www.irccloud.com") && !prefs.contains("path") && prefs.contains("session_key")) { Crashlytics.log(Log.INFO, "IRCCloud", "Migrating path from session key"); SharedPreferences.Editor editor = prefs.edit(); editor.putString("path", "/websocket/" + prefs.getString("session_key", "").charAt(0)); editor.commit(); } if (prefs.contains("host") && prefs.getString("host", "").equals("www.irccloud.com")) { Crashlytics.log(Log.INFO, "IRCCloud", "Migrating host"); SharedPreferences.Editor editor = prefs.edit(); editor.putString("host", "api.irccloud.com"); editor.commit(); } if (prefs.contains("gcm_app_version")) { SharedPreferences.Editor editor = prefs.edit(); editor.remove("gcm_app_version"); editor.remove("gcm_app_build"); editor.remove("gcm_registered"); editor.remove("gcm_reg_id"); editor.commit(); } NetworkConnection.IRCCLOUD_HOST = prefs.getString("host", BuildConfig.HOST); NetworkConnection.IRCCLOUD_PATH = prefs.getString("path", "/"); /*try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)) WebView.setWebContentsDebuggingEnabled(true); } } catch (Exception e) { }*/ /*FontRequest request = new FontRequest( "com.google.android.gms.fonts", "com.google.android.gms", "Dekko", R.array.com_google_android_gms_fonts_certs); FontsContractCompat.requestFont(getApplicationContext(), request, new FontsContractCompat.FontRequestCallback() { @Override public void onTypefaceRetrieved(Typeface typeface) { csFont = typeface; EventsList.getInstance().clearCaches(); NetworkConnection.getInstance().notifyHandlers(NetworkConnection.EVENT_FONT_DOWNLOADED, null); } }, getFontsHandler());*/ Crashlytics.log(Log.INFO, "IRCCloud", "App Initialized"); }
From source file:com.example.android.scopeddirectoryaccess.ScopedDirectoryAccessFragment.java
private String getDirectoryName(String name) { switch (name) { case "ALARMS": return Environment.DIRECTORY_ALARMS; case "DCIM": return Environment.DIRECTORY_DCIM; case "DOCUMENTS": return Environment.DIRECTORY_DOCUMENTS; case "DOWNLOADS": return Environment.DIRECTORY_DOWNLOADS; case "MOVIES": return Environment.DIRECTORY_MOVIES; case "MUSIC": return Environment.DIRECTORY_MUSIC; case "NOTIFICATIONS": return Environment.DIRECTORY_NOTIFICATIONS; case "PICTURES": return Environment.DIRECTORY_PICTURES; case "PODCASTS": return Environment.DIRECTORY_PODCASTS; case "RINGTONES": return Environment.DIRECTORY_RINGTONES; default://from w ww .j av a 2s .com throw new IllegalArgumentException("Invalid directory representation: " + name); } }