开发者

Access static final variables on a class in one app, from another app

开发者 https://www.devze.com 2023-03-10 08:22 出处:网络
While I continue to ponder this for the technical consequences that hitting \'compile\' generates, shouldn\'t I be able to access static final variables on a class in one project/app, from another pro

While I continue to ponder this for the technical consequences that hitting 'compile' generates, shouldn't I be able to access static final variables on a class in one project/app, from another project/app? The one project is in the build path of the other. It compiles but throws a NoClassDefFound error at runtime.

Both apps are mine, so I have a bit of freedom here, though I don't think sharing the user id and process is involved here. I开发者_开发问答t's important that the class stays within one of the projects. I'm not looking for solutions like Android Library Projects or JAR libraries.

EDIT: After consideration, I'm abandoning this idea since it had a few logic mistakes. What I really want seems to be to let the first app offer some function to the second. I.e. so that the second app can send the first some data, and get a result back. The functionality has little domain related value, rather a technical one, so I'd like the shortest simplest solution.


Each app instance is sandboxed, so you can't get directly at the memory of another process. Unencumbered data sharing between apps as you suggest would amount to a gaping security hole.

If you need to communicate between apps to share data, look into the ContentProvider

From the docs:

Content providers store and retrieve data and make it accessible to all applications. They're the only way to share data across applications; there's no common storage area that all Android packages can access.

EDIT:

After consideration, I'm abandoning this idea since it had a few logic mistakes. What I really want seems to be to let the first app offer some function to the second. I.e. so that the second app can send the first some data, and get a result back. The functionality has little domain related value, rather a technical one, so I'd like the shortest simplest solution.

There's a solution for that too. Intents

0

精彩评论

暂无评论...
验证码 换一张
取 消