I’d like produce an app that serves as an convenient entry-point to a third-party app, starting one of its activities with my parameters rather than clicking through it to do the same. I know a bit about the third-party app: I need an Intent with a single.putExtra, to a known string, of an instance of a Payload class defined by the app, the definition of which is known to me.
My question: how can I send my own intent with an object that will be accepted as the app’s own Payload? I.e., if it’s defined as (tersely expressed)
public class Payload implements Serializable {
private String url;
Payload(String url) { this.url = url; }
public String getUrl() { return url; }
}
can I define my own
public class NotPayload implements Serializable {
private String x;
Payload(String x) { this.x = x; }
}
in my own application, and send the intent? Is there more involved?
For the wary, there’s nothing remotely malicious about what I aim to do. I’d just like to supplement an app, and plan to share the result with its developers (OK, with the subtext of “would you like to add this feature already?”)
No, this won’t work.
You will be able to store the data on your side, using your class. The Intent code will serialize your object into byte data. The code inside the third-party app will try to deserialize the data back into an object. This will fail. Serializable data can only be deserialized into the same class.
Copy the definition of the original class, as is, without changing the class name or package.