我正在按照GoogleIO(http://www.youtube.com/watch?v=xHXn3Kg2IQE)的建议在Android上实现RESTful服务的消费(我的第一次Android体验)。我尝试实现一个GET请求,我认为我按照提议实现了所有内容,但似乎没有起作用。
以下是我的ServiceHelper和Service类:
调试后我知道它在ServiceHelper类中得到了getPersons()方法:
public void getPersons ( Context context, ResultReceiver receiver ) {
final Intent intent = new Intent ( Intent.ACTION_SYNC, null, context, PersonService.class );
intent.putExtra ( PersonService.EXTRA_STATUS, receiver );
intent.putExtra ( PersonService.EXTRA_REST_OPERATION, PersonService.GENERAL_REST_OPERATION );
context.startService ( intent );
}
但是,它永远不会到达Service类中的onCreate(),onHandleIntent()或getPersons():
@Override
protected void onHandleIntent ( Intent intent ) {
Log.d ( TAG, "onHandleIntent()" );
final String restOperation = intent.getStringExtra ( EXTRA_REST_OPERATION );
if ( GENERAL_REST_OPERATION.equals ( restOperation ) )
getPersons ( intent );
}
你知道这里出了什么问题吗?
提前感谢您的帮助!