简体   繁体   中英

How can I parse Parcel object in host instead of android device?

I want to communicate with an APP in android device using socket. We will send and receive many parcel objects . App will get some system information and it will be easier using parcel. So I have to do more things to parse parcel object...

I can use python or java or jython. But there are no tools to parse parcel.

I want to use Parcel class in android by android.jar, but Exception in thread “main” java.lang.RuntimeException: Stub , Because android.jar cant use in standalone project .

I try Robolectric , But Parcel need native write and read. I get libandroid_runtime.so and load it, wrong ELF class: ELFCLASS32 (I work in 64bit ubuntu)...

Except transplant android code to host, are there other methods? Thanks!

I beleive that using of gson library is more native and usual way for network communication on Android.

If it does not fit your needs, you can use Serializable with custon writeObject/readObject, but I would strongly advise you to json because it is easier to debug and you dont need to care about 100% Serializable compartibility.

Parcel and Parcelable are designed for use within a device. They are not well-suited for use between different environments, and they are useless outside of Android.

Please use something else for cross-environment/cross-language communciation, like JSON, XML, protobuf , or Thrift .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM