Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 是否可以从另一个服务启动IntentService_Android_Google Cloud Messaging_Android Intentservice - Fatal编程技术网

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

Android 是否可以从另一个服务启动IntentService,android,google-cloud-messaging,android-intentservice,Android,Google Cloud Messaging,Android Intentservice,从某种意义上说,这是一个独特的问题,我传递stringExtra来启动IntentService,而不是从服务内部启动服务(我的问题被标记为可能的重复)。我正试图通过传递intent从gcminentservice启动IntentService。有可能吗?或者我必须将数据发送到活动中的广播接收器,并将其传递给意向服务?我的目标是从单独的线程向设备发送位置更新 Intent iniupdates = new Intent(this, LocationUpdater.class); iniupdat

从某种意义上说,这是一个独特的问题,我传递stringExtra来启动IntentService,而不是从服务内部启动服务(我的问题被标记为可能的重复)。我正试图通过传递intent从gcminentservice启动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已启动。

请参阅答案。这可能会对您有所帮助。该问题解决了您希望从活动启动服务的场景。我想通过添加一些stringExtra从另一个服务(GCMinentService)启动IntentService。IntentService没有启动,如果我在清单中声明它,我会得到npe,这很奇怪。