I am facing one weired problem. I have defined my service action in string.xml and using the same in manifest like this:
<service android:name=".MyService" >
<intent-filter >
<action android:name="@string/my_service_action" />
</intent-filter>
</service>
Also while starting the service I am starting like this:
Intent serviceIntent = new Intent(getResources().getString(R.string.my_service_action));
startService(serviceIntent);
Can anyone tell me where is the problem.
If I hard code the same value of action, it works perfectly fine. After some hit n try I found that it doesn’t work only when used in manifest file(e.g. hard code the action value in java code only not manifest).
I dont think you can use string reference as action string for service. It must a concrete string value. As per javadoc:
For example:
and then you should use it as: