是否可以从另一个服务启动IntentService

时间:2015-10-08 08:27:55

标签: android google-cloud-messaging android-intentservice

这是一个独特的问题,在某种意义上说,我传递stringExtra来启动IntentService而不是简单地从服务中启动服务的问题(我的问题被标记为可能重复)。我试图通过传递意图从GcmIntentService启动IntentService。它可能吗?或者我必须将数据发送到活动中的广播接收器并将它们传递给意向服务?我的目标是从单独的线程将位置更新发送到设备。

Intent iniupdates = new Intent(this, LocationUpdater.class);
iniupdates.putExtra(LocationUpdater.PARAM_IN_PAS, pa);
iniupdates.putExtra(LocationUpdater.PARAM_IN_DRI, tok);
startService(iniupdates);

我想收到这个

@Override
protected void onHandleIntent(Intent intent) {
    if (intent != null) {
        pa = intent.getStringExtra(PARAM_IN_PAS);
        dr = intent.getStringExtra(PARAM_IN_DRI);
        Log.e("onhandle", dr);
    } else{
        Log.e("ERROR", "YOUR INTENT IS NULL");
    }
}

但我没有得到任何东西。我甚至都没有看到我的IntentService已经启动。

0 个答案:

没有答案