我在这一行 wsresult = restClientInterface.skuska(); 上遇到空指针异常;用于restClientInterface。这是我的示例:
import org.springframework.http.converter.json.GsonHttpMessageConverter;
import com.googlecode.androidannotations.annotations.rest.Get;
import com.googlecode.androidannotations.annotations.rest.Rest;
@Rest(rootUrl = "http://my_ip_address/webresources", converters = {GsonHttpMessageConverter.class})
public interface RestClient {
@Get("/persons")
String skuska();
}
我正在使用它片段
@EFragment
public class HomeFragment extends Fragment {
private Button ws;
private TextView wsstring;
private String wsresult;
@RestService
RestClient restClientInterface;
wsstring = (TextView) view.findViewById(R.id.wsstring);
ws = (Button) view.findViewById(R.id.ws);
ws.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
getWSResult();
wsstring.setText(wsresult);
}
});
return view;
}
@Background
public void getWSResult() {
wsresult = restClientInterface.skuska();
}