Android - pass large amount of data to service running on a different process

╄→гoц情女王★ 提交于 2021-01-28 01:10:06

问题


is there any possible way to pass a large amount of data into an Android Service that runs on a different process from the main activity? The data to pass is a byte array of around 5Mb. As notes, I cannot save the data to file to do the transfer, needs to be transferred purely via memory or any other way which isn't to persist to file, databases, etc.

I've tried via AIDL, but seems in Android under AIDL the parcelable data is limited 1Mb. Also slicing the data and transferring it via chunks is not an option. Should be 1 single transaction. I've also tried Intents, but again the same limitations of 500Kb to 1Mb.

So I am running out of ideas.


回答1:


What about shared memory ashmem http://www.androidenea.com/2010/03/share-memory-using-ashmem-and-binder-in.html

Memory file is an ashmem wrapper http://developer.android.com/reference/android/os/MemoryFile.html

Or you could try opening a socket or ServerSocket in your service and connecting to it from your activity

http://developer.android.com/reference/java/net/ServerSocket.html



来源:https://stackoverflow.com/questions/17616811/android-pass-large-amount-of-data-to-service-running-on-a-different-process

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!