标题说真的,我正在努力将我的界面实例发送到asynctask
服务:
public class CompletedPicks extends Service implements AsyncResponseForCompletedPick {
PickList p;
Context ctx;
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate(Context _ctx)
{
this.ctx = _ctx;
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
boolean haveConnectedWifi = false;
ConnectivityManager cm = (ConnectivityManager) getBaseContext().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo[] netInfo = cm.getAllNetworkInfo();
for (NetworkInfo ni : netInfo) {
if (ni.getTypeName().equalsIgnoreCase("WIFI"))
if (ni.isConnected())
haveConnectedWifi = true;
}
if (haveConnectedWifi)
{
PickListTableOps PLTO = new PickListTableOps(getBaseContext());
List<PickList> myList = PLTO.GetItemsReadyForUpload();
if(myList.size() > 0) {
for (int i = 0; i < myList.size(); i++)
{
p = myList.get(i);
int result = new CompletedPick(getBaseContext(),this ,p);
}
}
}
handler.postDelayed(this, 10000);
}
}, 10000);
}
@Override
public void returnsuccess(Integer integer, PickList p) {
PickListTableOps PLTO = new PickListTableOps(getBaseContext());
PLTO.UpdateSentStatus(this.p.getPicklist_id(), this.p.getSku_id());
}
任务:
public myTask(Context ctx, myInterface in, PickList p)
我已经尝试了Context和myservice.this的一个实例,但无法找出我需要发送的引用。
这是一个服务,而不是一个IntentService,所以httprequests(我的AsyncTask处理的)需要在一个单独的线程上完成
由于
答案 0 :(得分:0)
好的,amatuer错误,我有两个密切命名的任务!
这样做:
new CompletedPick(getBaseContext(),CompletedPicks.this ,p).execute();