我正在尝试从服务中调用局外人类,但遇到“空指针异常”之类的错误。这是简单的代码。
这里是局外人课。
public class SyncTask {
private Context context;
public SyncTask(Context context, String agrs) {
this.context = context;
}
protected String ProcessSycn(String agrs) {
return agrs + " - call successful.";
}
}
这里是服务类。
public class SyncService extends Service{
public SyncTask syncme;
public String i;
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
super.onStart(intent, startId);
i = syncme.ProcessSycn(3 + "");
this.stopSelf();
}
@Override
public void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
}
}