I am trying to start IntentService from BroadcastReceiver like ( in onReceive(Context context, Intent intent) function):
Intent i = new Intent(context, RegService.class);
i.putExtra("user_id", userId);
i.putExtra("device_id", "bla");
context.startService(i);
and RegService like
public class RegService extends IntentService {
public RegService(String name) {
super(name);
}
public RegService(){
super("RegService");
}
@Override
protected void onHandleIntent(Intent intent) {
// TODO Auto-generated method stub
String c2dm_registration_id = intent
.getStringExtra("c2dm_registration_id");
String token = intent.getStringExtra("token");
String userId = intent.getStringExtra("user_id");
String device_type = "android";
try {
JSONObject object = RestClient.sendC2DMRegistrationId(
c2dm_registration_id, device_type,
token, userId);
} catch (Exception e) {
e.printStackTrace();
}
}
}
but I cannot enter in onHandle in RegService ( I passed through first code context.startService(i); but I cannot enter in onHandle, no message ). Did anybody have same experience and waht is a solution ? I have in manifest
<service
android:enabled="true"
android:name=".c2dm.RegService" />