我在变量中有上下文,我怎么知道上下文是否是intentService?
public void syncToServer(Context context){
if ( is intentService ){
hpptClientSend();
}else{
hpptClientAsyncSend();
}
}
问题是我想在使用httpclient的intentservice AsyncTask中使用,因为android不允许服务中的并行线程: An asyncTask launched from an onPostExecute of another AsyncTask does not execute properly in API 10
我需要将httpClient用于IntentService,但是我在UI线程中使用了相同的函数,需要AsynkTask。
答案 0 :(得分:0)
在Java中,使用instanceof
运算符来确定对象是否是某个类或接口的实例。因此,如果context instanceof IntentService
是true
(或context
的某个子类),IntentService
的实例,则IntentService
将为false
。