0

Let's say that I have an Android library that has static class Foo in it. Foo will hold data (like a Map), and will have an Add function that will take a String key and an Object object (Example, Foo.Add("Test1",1)). You can also retrieve the item by calling Foo.Get("Test1") and it will return the item associated with Test1

I have 2 seperate apps that have this library included in their source code.

If in App 1 I call Foo.Add("Test1",1). In App 2 if I call Foo.Get("Test1") will I get a null pointer exception or will I get 1?

I am not sure exactly how static classes in included libraries work, scope wise.

I don't want to hear why this is good, or bad, or how this goes against whatever you think your religion is, or that Jazz. I am curious about the problem I have proposed.

miversen33
  • 573
  • 5
  • 19
  • 2
    "Let's say that I have an Android library that has static class Foo in it" -- your definition of "static class" would appear to differ from [how Java programmers use the term](http://stackoverflow.com/questions/7486012/static-classes-in-java). "will I get a null pointer exception or will I get 1?" -- App 2 will be unaffected by anything you do in App 1 by default. – CommonsWare Oct 01 '15 at 23:57
  • It seems you are correct about the static class part. And I am not currently home to test it which is why I asked as opposed to tried. Aside from intents, is there anyway to accomplish something of this nature in android? – miversen33 Oct 02 '15 at 00:03
  • "Aside from intents, is there anyway to accomplish something of this nature in android?" -- to communicate between processes, you have to use some form of IPC. Most of those involve `Intent` objects, but not all (e.g., `ContentProvider`). – CommonsWare Oct 02 '15 at 00:09
  • Im not a fan of intents. Any links to other IPC ideas? – miversen33 Oct 02 '15 at 00:48

0 Answers0