I am adding Android C2DM to the Android library project. I started with com.google.android.c2dm package , which is included in JumpNote and Chrome for the phone . To use this package, you must subclass the C2DMBaseReceiver service .which takes the sender id as an argument to its constructor. In JumpNote, this argument is initialized using a hard-coded static variable in the configuration class. However, in an Android library project that can be used by several simultaneously running applications, I don’t think I can use a hard-set static variable (that is, I believe that this can lead to problems when / if several applications try to access / change a static variable )
I tried to come up with a way to initialize the sender ID without using a static variable and is still irrelevant.
The obvious solution would be to use a manifest string or resource or combination 2. For example, in the strings.xml file, I might have the string "ac2dmSender" that is accessed in the child metadata declaration declaration C2DMReceiver in the manifest. However, it seems that you cannot get a reference to the PackageManager or ResourceManager from a static context, so I cannot get the metadata in such a way as to pass it to the C2DMBaseReceiver constructor.
Please let me know that I missed something! Thanks in advance.
source
share