Using startActivityForResult across Android applications

后端 未结 2 815
一向
一向 2021-01-22 07:01

I have written an application that has an so that other applications can start it using startActivityForResult(). When this acti

2条回答
  •  温柔的废话
    2021-01-22 07:53

    how does it know the name of the intent extra to receive

    By reading the API documentation published by the author of the first application.

    how would I create the object received and cast it back into a MyObject that is not part of of this application?

    The authors of the first application would also have to publish a JAR containing an implementation of MyObject, that the authors of the second application add to their project. And, the authors of the first application would either never have to change MyObject or at least make sure the serialization versioning stuff works.

    Would I just mimic the MyObject class in the second application and cast it to that?

    If by "mimic" you mean "have a class with the exact same class name, exact same package name, and exact same serialization logic", then yes, though I'm then concerned about your use of the term "just"... :-)

    If MyObject has the structure you describe, consider just putting the String and String[] as individual extras, or put them in a Bundle and use that as an extra, to avoid trying to use custom Parcelable objects between apps.

提交回复
热议问题