Cannot Start Service In Inner Class - Is It My Android Manifest?
Please help! I am desperate here!!!! I am having trouble starting my service. I moved it to an inner class within my Activity and I cannot get it to start! I don't know if I have t
Solution 1:
Your Service
must be a static class. Then once in your manifest, you will need to show it as so
<service android:name="HW07$PrimeService"/>
You could do something like this (pseudo)
classHM07extendsActivity {
publicstatic Handler mHandler;
// ...@OverridepublicvoidonCreate(Bundle icicle) {
super.onCreate(icicle);
// ...
mHandler = newHandler();
}
}
classPrimeServiceextendsService {
@OverridepublicvoidonStartCommand() {
Handlerhandler= HM07.mHandler;
handler.sendMessage(/* Message */);
}
}
Solution 2:
classoutclassextendsActivity {
// ...@OverridepublicvoidonCreate(Bundle icicle) {
super.onCreate(icicle);
// ...
}
publicstaticclassinnerServiceextendsService {
@OverridepublicvoidonStartCommand() {
//....
}
}
}
and you need to declare below to your Androidmanifest.xml
<service android:name=".outclass$innerService"/>
note the dollar sign !
Post a Comment for "Cannot Start Service In Inner Class - Is It My Android Manifest?"