List of usage examples for android.content Intent ACTION_MEDIA_SHARED
String ACTION_MEDIA_SHARED
To view the source code for android.content Intent ACTION_MEDIA_SHARED.
Click Source Link
From source file:org.chromium.ChromeSystemStorage.java
private static BackgroundEventHandler<ChromeSystemStorage> createEventHandler() { return new BackgroundEventHandler<ChromeSystemStorage>() { @Override// w ww.j ava 2 s . c o m public BackgroundEventInfo mapBroadcast(Context context, Intent intent) { String action = intent.getAction(); if (!(Intent.ACTION_MEDIA_MOUNTED.equals(action) || Intent.ACTION_MEDIA_BAD_REMOVAL.equals(action) || Intent.ACTION_MEDIA_REMOVED.equals(action) || Intent.ACTION_MEDIA_SHARED.equals(action) || Intent.ACTION_MEDIA_UNMOUNTED.equals(action))) { // Ignore any other actions return null; } BackgroundEventInfo event = new BackgroundEventInfo(action); event.getData().putString(DATA_STORAGE_PATH, intent.getDataString()); return event; } @Override public void mapEventToMessage(BackgroundEventInfo event, JSONObject message) throws JSONException { boolean attached = Intent.ACTION_MEDIA_MOUNTED.equals(event.action); // Sanitize the path provided with the event String storagePath = getBaseStoragePath( Uri.parse(event.getData().getString(DATA_STORAGE_PATH)).getPath()); ChromeSystemStorage plugin = getCurrentPlugin(); // The attached/detached events may fire before the client has a chance to call getInfo(). // Thus, must initialize the external storage here (if not already done), to ensure that // unit ids are consistent across calls to getInfo, and subsequent attach/detach events. StorageFile[] directories = plugin.initializeExternalStorageDirectories(); String unitId = plugin.getExternalStorageId(storagePath); StorageFile attachedStorage = null; if (attached) { attachedStorage = plugin.getExternalStorageDirectoryByPath(storagePath, directories); } else { // If the detached event causes initialization, the unit id may not be found // as it won't be reported in the list of directories. We can safely generate // a random id, as the client won't have called getInfo yet. if (unitId == null) { unitId = UUID.randomUUID().toString(); } } message.put("action", attached ? "attached" : "detached"); message.put("id", unitId); if (attached) { JSONObject storageUnit = plugin.buildExternalStorageUnitInfo(attachedStorage); message.put("info", storageUnit); } } }; }
From source file:com.nadmm.airports.ActivityBase.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDbManager = DatabaseManager.instance(this); mInflater = getLayoutInflater();/*from w w w . ja va 2 s .com*/ overridePendingTransition(R.anim.fade_in, R.anim.fade_out); mHandler = new Handler(); mFilter = new IntentFilter(); mFilter.addAction(Intent.ACTION_MEDIA_MOUNTED); mFilter.addAction(Intent.ACTION_MEDIA_SHARED); mFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED); mFilter.addAction(Intent.ACTION_MEDIA_REMOVED); mFilter.addDataScheme("file"); mExternalStorageReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { externalStorageStatusChanged(); } }; if (Application.sDonationDone == null) { DonateDatabase db = new DonateDatabase(this); Cursor c = db.queryAllDonations(); Application.sDonationDone = c.moveToFirst(); db.close(); } // Enable Google Analytics ((Application) getApplication()).getAnalyticsTracker(); }
From source file:com.loloof64.android.chess_position_manager.MainActivity.java
@Override protected void onResume() { super.onResume(); IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_MEDIA_REMOVED); filter.addAction(Intent.ACTION_MEDIA_BAD_REMOVAL); filter.addAction(Intent.ACTION_MEDIA_EJECT); filter.addAction(Intent.ACTION_MEDIA_NOFS); filter.addAction(Intent.ACTION_MEDIA_SHARED); filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED); registerReceiver(mStorageReceiver, filter); }
From source file:net.kidlogger.kidlogger.KLService.java
public void setupLogging() { // Set up GPS / Network logging if (Settings.loggingGps(this)) { startGpsUpdates();//from www . ja va 2s . c om gpsOn = true; } // Set up WiFi logging if (Settings.loggingWifi(this)) { wifiReceiver = new WifiReceiver(this); registerReceiver(wifiReceiver, new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION)); wifiOn = true; } // Set up SMS logging if (Settings.loggingSms(this)) { smsObserver = new SmsObserver(this, handlering); IntentFilter smsFilter = new IntentFilter(SMS_RECEIVED); registerReceiver(smsObserver.inSms, smsFilter); smsOn = true; } // Set up Calls logging if (Settings.loggingCalls(this)) { IntentFilter callsFilter = new IntentFilter(TelephonyManager.ACTION_PHONE_STATE_CHANGED); callsReceiver = new CallsReceiver(this); registerReceiver(callsReceiver, callsFilter); callOn = true; } // Set up Idle logging IntentFilter idleFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF); idleFilter.addAction(Intent.ACTION_USER_PRESENT); idleReceiver = new IdleReceiver(this); registerReceiver(idleReceiver, idleFilter); idleOn = true; /*if(Settings.loggingIdle(this)){ IntentFilter idleFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF); idleFilter.addAction(Intent.ACTION_USER_PRESENT); idleReceiver = new IdleReceiver(this); registerReceiver(idleReceiver, idleFilter); idleOn = true; }*/ // Set up URL logging if (Settings.loggingUrl(this)) { urlObserver = new HistoryObserver(this, handlering); urlOn = true; } // Set up USB logging if (Settings.loggingUsb(this)) { IntentFilter usbFilter = new IntentFilter(Intent.ACTION_UMS_CONNECTED); usbFilter.addAction(Intent.ACTION_UMS_DISCONNECTED); usbReceiver = new UsbReceiver(this); registerReceiver(usbReceiver, usbFilter); usbOn = true; } // Set up Tasks logging if (logTask) { // Check if a new Application was started taskScan = new Runnable() { public void run() { new Thread(new Runnable() { public void run() { doScanTask(); } }).start(); if (userPresent) { handleTask.postDelayed(this, SCAN_TASK_TIME); scanningTask = true; } else { scanningTask = false; } } }; handleTask.postDelayed(taskScan, SCAN_TASK_TIME); taskOn = true; } // Set up Clipboard logging if (logClip) { // Scan clipboard content, only first 30 characters clipboardScan = new Runnable() { public void run() { new Thread(new Runnable() { public void run() { doScanClipboard(); } }).start(); if (userPresent) { handleClipb.postDelayed(this, SCAN_CLIP_TIME); scanningClip = true; } else { scanningClip = false; } } }; handleClipb.postDelayed(clipboardScan, SCAN_CLIP_TIME); clipOn = true; } // Set up Power logging if (Settings.loggingPower(this)) { IntentFilter powerFilter = new IntentFilter(Intent.ACTION_SHUTDOWN); powerReceiver = new ShutdownReceiver(this); registerReceiver(powerReceiver, powerFilter); powerOn = true; } // Set up Memory Card logging if (Settings.loggingMedia(this)) { IntentFilter mediaFilter = new IntentFilter(Intent.ACTION_MEDIA_REMOVED); mediaFilter.addAction(Intent.ACTION_MEDIA_BAD_REMOVAL); mediaFilter.addAction(Intent.ACTION_MEDIA_MOUNTED); mediaFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED); mediaFilter.addAction(Intent.ACTION_MEDIA_SHARED); mediaFilter.addDataScheme("file"); mediaReceiver = new MediaReceiver(this); registerReceiver(mediaReceiver, mediaFilter); mediaOn = true; } // Set up GSM logging if (Settings.loggingGsm(this)) { gsmObserver = new GsmObserver(this); telManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); telManager.listen(gsmObserver, PhoneStateListener.LISTEN_SERVICE_STATE | PhoneStateListener.LISTEN_CELL_LOCATION); gsmOn = true; } // Set up Airplane mode receiver if (Settings.loggingAir(this)) { IntentFilter airFilter = new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED); airReceiver = new AirplaneReceiver(this); registerReceiver(airReceiver, airFilter); airOn = true; } // Set up Photos logging if (Settings.loggingPhotos(this)) { photoObserver = new PhotoObserver(this, this, handlering); photoOn = true; } // Set up SliceMultimediaFile if (Settings.uploadPhotos(this) || Settings.uploadRecords(this)) { mediaSlicer = new SliceMultimediaFile(this); } // Set up ConnectivityReceiver mConReceiver = new ConnectivityReceiver(this); registerReceiver(mConReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); // Ser up CallIntentReceiver //outCallReceiver = new CallIntentReceiver(); //registerReceiver(outCallReceiver, new IntentFilter(KLService.OUTGOING_CALL)); }
From source file:com.android.server.MountService.java
private void notifyVolumeStateChange(String label, String path, int oldState, int newState) { final StorageVolume volume; final String state; synchronized (mVolumesLock) { volume = mVolumesByPath.get(path); state = getVolumeState(path);/*from w ww . ja va 2 s .c o m*/ } if (DEBUG_EVENTS) Slog.i(TAG, "notifyVolumeStateChange::" + state); String action = null; if (oldState == VolumeState.Shared && newState != oldState) { if (LOCAL_LOGD) Slog.d(TAG, "Sending ACTION_MEDIA_UNSHARED intent"); sendStorageIntent(Intent.ACTION_MEDIA_UNSHARED, volume, UserHandle.ALL); } if (newState == VolumeState.Init) { } else if (newState == VolumeState.NoMedia) { // NoMedia is handled via Disk Remove events } else if (newState == VolumeState.Idle) { /* * Don't notify if we're in BAD_REMOVAL, NOFS, UNMOUNTABLE, or * if we're in the process of enabling UMS */ if (!state.equals(Environment.MEDIA_BAD_REMOVAL) && !state.equals(Environment.MEDIA_NOFS) && !state.equals(Environment.MEDIA_UNMOUNTABLE) && !getUmsEnabling()) { if (DEBUG_EVENTS) Slog.i(TAG, "updating volume state for media bad removal nofs and unmountable"); updatePublicVolumeState(volume, Environment.MEDIA_UNMOUNTED); action = Intent.ACTION_MEDIA_UNMOUNTED; } } else if (newState == VolumeState.Pending) { } else if (newState == VolumeState.Checking) { if (DEBUG_EVENTS) Slog.i(TAG, "updating volume state checking"); updatePublicVolumeState(volume, Environment.MEDIA_CHECKING); action = Intent.ACTION_MEDIA_CHECKING; } else if (newState == VolumeState.Mounted) { if (DEBUG_EVENTS) Slog.i(TAG, "updating volume state mounted"); updatePublicVolumeState(volume, Environment.MEDIA_MOUNTED); action = Intent.ACTION_MEDIA_MOUNTED; } else if (newState == VolumeState.Unmounting) { action = Intent.ACTION_MEDIA_EJECT; } else if (newState == VolumeState.Formatting) { } else if (newState == VolumeState.Shared) { if (DEBUG_EVENTS) Slog.i(TAG, "Updating volume state media mounted"); /* Send the media unmounted event first */ updatePublicVolumeState(volume, Environment.MEDIA_UNMOUNTED); sendStorageIntent(Intent.ACTION_MEDIA_UNMOUNTED, volume, UserHandle.ALL); if (DEBUG_EVENTS) Slog.i(TAG, "Updating media shared"); updatePublicVolumeState(volume, Environment.MEDIA_SHARED); action = Intent.ACTION_MEDIA_SHARED; if (LOCAL_LOGD) Slog.d(TAG, "Sending ACTION_MEDIA_SHARED intent"); } else if (newState == VolumeState.SharedMnt) { Slog.e(TAG, "Live shared mounts not supported yet!"); return; } else { Slog.e(TAG, "Unhandled VolumeState {" + newState + "}"); } if (action != null) { sendStorageIntent(action, volume, UserHandle.ALL); } }