当Intent.ACTION_MEDIA_EJECT时如何获得额外的形式意图?

时间:2013-06-21 15:53:31

标签: android

我把我的广播接收器放入行动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  

但是为key定义了字符串:storage_volume

因为我想这样做:

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

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

1 个答案:

答案 0 :(得分:1)

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

请参阅StorageVolume.java