【发布时间】:2015-07-27 17:50:29
【问题描述】:
我在一个变量中有上下文,我怎么知道上下文是不是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
我需要在 IntentService 中使用 httpClient,但我在 UI 线程中使用了相同的功能并且需要 AsynkTask。
【问题讨论】:
-
如何将 Intent 对象作为参数传递给
syncToServer? -
"我如何知道上下文是 Intent 还是 intentService?" --
Intent不扩展Context。 -
njzk2 谢谢 :) 工作正常。 CommonsWare 你是对的,它是活动或意图服务。 ρяσѕρєя 非常难,有很多函数依赖于它,尽管有可能,但你必须修改所有类型的函数才能实现这一点。
标签: java android multithreading android-intent android-asynctask