简体   繁体   English

我该如何解析主机而非Android设备中的Parcel对象?

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

I want to communicate with an APP in android device using socket. 我想使用套接字与Android设备中的APP通信。 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. 我可以使用python或java或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 . 我想通过android.jar在android中使用Parcel类,但是Exception in thread “main” java.lang.RuntimeException: Stub ,因为android.jar不能在独立项目中使用

I try Robolectric , But Parcel need native write and read. 我尝试使用Robolectric ,但是Parcel需要本机写入和读取。 I get libandroid_runtime.so and load it, wrong ELF class: ELFCLASS32 (I work in 64bit ubuntu)... 我得到libandroid_runtime.so并加载它, wrong ELF class: ELFCLASS32 (我在64位ubuntu中工作)...

Except transplant android code to host, are there other methods? 除了将android代码移植到主机上,还有其他方法吗? Thanks! 谢谢!

I beleive that using of gson library is more native and usual way for network communication on Android. 我相信gson库的使用是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. 如果它不符合您的需求,则可以将SERIALizable与custon writeObject / readObject一起使用,但是我强烈建议您使用json,因为它更易于调试,并且您不需要关心100%的Serializable兼容性。

Parcel and Parcelable are designed for use within a device. ParcelParcelable专为在设备内使用而设计。 They are not well-suited for use between different environments, and they are useless outside of Android. 它们不太适合在不同环境之间使用,并且在Android之外毫无用处。

Please use something else for cross-environment/cross-language communciation, like JSON, XML, protobuf , or Thrift . 请使用其他内容进行跨环境/跨语言通信,例如JSON,XML, protobufThrift

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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