Uygulamam için Google Cloud Uç Noktalarını kullanarak bir arka plan oluşturmaya çalışıyorum ve her şey doğru bir şekilde veri deposuna girmeye çalışana kadar iyi gidiyor gibiydi.Google Cloud Endpoint, istemciden çalışmıyor Ekle
Oluşturulan uç noktaları kullanarak GenericBike nesnelerini veri deposuna eklemeye çalışıyorum ve kod derler ve başarılı bir şekilde çalışıyor gibi görünürken, proje web sayfasını kontrol ettiğimde hiçbir şey gerçekten eklenmez.
Gerçekte eklemek için kodum İşte. Ben yardımcı durumunda bunu
if (mGenericBikes == null) { // we need to preload the database still
for (int i=0; i<10; i++) {
GenericBike bike = new GenericBike();
bike.setId(new Long(i+1));
new AddGenericBikeAsyncTask().execute(bike);
}
}
diyoruz burada nerede
private class AddGenericBikeAsyncTask extends AsyncTask<GenericBike, Void, Void> {
@Override
protected Void doInBackground(GenericBike... params) {
GenericBikeApi.Builder builder = new GenericBikeApi.Builder(AndroidHttp.newCompatibleTransport(),
new AndroidJsonFactory(), null)
.setRootUrl("https://banded-coder-125919.appspot.com/_ah/api/");
GenericBikeApi service = builder.build();
try {
GenericBike bike = params[0];
Log.e("Debug", "Inserting bike...");
service.insert(bike);
Log.e("Debug", "Done inserting bike.");
} catch (IOException e) {e.printStackTrace(); }
return null;
}
}
Ve burada, benim GenericBike eden taraf olduğunu.
@Entity
public class GenericBike {
@Id Long mId;
boolean mAtStation;
public GenericBike() {
mAtStation = true;
}
public Long getId() {
return mId;
}
public void setId(Long id) {
mId = id;
}
public boolean isAtStation() {
return mAtStation;
}
public void setAtStation(boolean atStation) {
mAtStation = atStation;
}
DÜZENLEME: Burada istemciden istek başlatarak değil gibi
/**
* Inserts a new {@code GenericBike}.
*/
@ApiMethod(
name = "insert",
path = "genericBike",
httpMethod = ApiMethod.HttpMethod.POST)
public GenericBike insert(GenericBike genericBike) {
// Typically in a RESTful API a POST does not have a known ID (assuming the ID is used in the resource path).
// You should validate that genericBike.mId has not been set. If the ID type is not supported by the
// Objectify ID generator, e.g. long or String, then you should generate the unique ID yourself prior to saving.
//
// If your client provides the ID then you should probably use PUT instead.
ofy().save().entity(genericBike).now();
logger.info("Created GenericBike.");
return ofy().load().entity(genericBike).now();
}
Sorunu açıklamak ister misiniz? – Gendarme
@Gendarme, özür dilerim, beynim şu anda biraz kızarmış. Uç noktaları kullanarak GenericBike nesnelerini veri deposuna eklemeye çalışıyorum ve kod derler ve başarılı bir şekilde çalışıyor gibi görünürken, proje web sayfasını kontrol ettiğimde hiçbir şey gerçekten eklenmez. – noblera
sadece "GenericBikeApi.Insert" yöntem kodu gönderebiliyorsanız bunu çözebiliriz .. !!! –