0

我把我的广播接收器放入行动 ACTION_MEDIA_EJECT

if(action.equals(Intent.ACTION_MEDIA_EJECT)){
       for(String k : intent.getExtras().keySet()){
        Log.d("arek","klucz = "+k);
        Log.v("arek","wartość= "+intent.getExtras().get(k).toString());
 }

并进入日志:

05-10 15:13:33.871: D/arek(10322): klucz = storage_volume
05-10 15:13:33.871: V/arek(10322): wartość= StorageVolume [mStorageId=131073 mPath=/storage/extSdCard mDescriptionId=17041195 mPrimary=false mRemovable=true mEmulated=false mMtpReserveSpace=0 mAllowMassStorage=false mMaxFileSize=0 mOwner=null mSubSystem=sd mActivitySecureContainer=false]
05-10 15:13:33.881: I/arek(10322): mStorageManager.getVolume(filePath).getStorageId() = 131073  

但是在哪里定义了键的字符串:storage_volume

因为我想做:

StorageVolume sv = (StorageVolume) intent.getExtras().get("storage_volume");

那么用字符串“storage_volume”定义的常量值在哪里呢?

4

1 回答 1

1

android.os.storage.StorageVolume.EXTRA_STORAGE_VOLUME。但是这个类本身是隐藏的。

请参阅StorageVolume.java

于 2013-06-21T16:00:54.800 回答