Intent的putParcelableArrayListExtra方法可以设置ArrayList<HashMap<String, Object>>值吗?
我想在intent中加上ArrayList<HashMap<String, Object>>类型的值通过broadc传递到activity中。
如下所示,但是提示错误,
ArrayList<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>();
intent1.putParcelableArrayListExtra("listItem", listItem);
错误信息:
The method putParcelableArrayListExtra(String, ArrayList<? extends Parcelable>) in the type Intent is not applicable for the arguments (String, ArrayList<HashMap<String,Object>>)
那么,putParcelableArrayListExtra具体是怎么用的呢?
通过实现Parcelable接口,能返回ArrayList<HashMap<String, Object>>对象吗?
[解决办法]
private static final String EXTRA_DIRECTORY = "com.blackmoonit.intent.extra.DIRECTORY";void createPlaylist(ArrayList<Uri> aFileList) { String theDefaultFolderPath = "/sdcard/playlists"; Intent theIntent = new Intent(Intent.ACTION_SEND_MULTIPLE); theIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM,aFileList); theIntent.setType("audio/*"); theIntent.putExtra(EXTRA_DIRECTORY,theDefaultFolderPath); //optional try { startActivity(theIntent); } catch (Exception e) { e.printStackTrace(); }}