My Wiki!

My Android tutorial

Cross project references

Project dependency

Add project dependency will allow project to compile. But in runtime there will be error that the implementation is not available (VFY error). It the same as if one project uses classes from other projects in workspace. These classes will not be found in runtime. This can be fix by adding 'class folders' which hold classes generated by other projects.

But there is still problem if an application retrieves an object from other application as Ibinder (through binding services) and try to cast it to original service object. Although they are the same class as of compile time but are loaded by different loaders and Android treats them as 2 different classes. This will cause ClassCastException (see the discussion http://stackoverflow.com/questions/6630775/bindservice-from-other-app-but-same-userid-process)

The ultimate solution might be using android lib project or AIDL.

Preferenc

Tabactivity

Binding to service from child activities

When call only bindService() or 'unbindService()', parent (tab) activity can't recognize the service correctly. Sample error:

E/AndroidRuntime( 8570): FATAL EXCEPTION: main
E/AndroidRuntime( 8570): java.lang.RuntimeException: Unable to stop activity {de.dai.dtn/de.dai.dtn.dtnchat.MainTabActivity}: java.lang.RuntimeException: Unable to stop activity {de.dai.dtn/de.dai.dtn.dtnchat.DtnChatActivity}: java.lang.IllegalArgumentException: Service not registered: de.dai.dtn.dtnchat.DtnChatActivity$1@41108bd8
E/AndroidRuntime( 8570): 	at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:2806)

Correct usage:

  getApplicationContext().unbindService(mConnection);

Navigation