I am developing an app with Android Studio 1.0 with Google App Engine. I have created an App Engine Java Endpoints Module from Android Studio. Thus it created a lot of files, added dependencies in gradle automatically. In the template that was generated by Android Studio I saw aa class named MyBean
, which I can use for sending data through endpoints. Now there is another class MyEndpoint
which is the endpoint class I am exposing.
in MyEndpoint
class there is an endpoint method,
@ApiMethod(name = "sayHi")
public MyBean sayHi(@Named("name") String name) {
MyBean response = new MyBean();
response.setData(name);
return response;
}
Notice that The function parameter is a String value. Suppose I want to pass an Object of class MyBean
to this method. I can do that by just doing this
public MyBean sayHi(MyBean testBean)
my Mybean
class is
public class MyBean {
private String myData;
private byte[] imageByte;
public void setData(){
}
public String getData() {
return myData;
}
public void setData(String data1) {
myData = data1;
}
public void setImageByte(byte b[]){
imageByte = b;
}
public byte[] getImageByte() {
return imageByte;
}
}
Notice I added setImageBye
and getImageByte
methods. The problem is when I try to call my methods from my android java classes, setImageBye
and getImageByte
methods are not detected.
I saw that it only detects getData
and setData
methods.
But the getData
and setData
methods are not the methods defined in MyBean
class. When I used find usages in Android Studio i saw that they were defined automatically in some other class which sources cannot be found and they defined setData
by this
public com.example.shubhashis.myapplication.backend.myApi.model.MyBean setData(java.lang.String data) { /* compiled code */ }
So How can I use a class that I can use to communicate between the Backend and Android java classes. So that I can send it as a parameter in backend ApiMethod? So the class can be used as a middle ground?
The app
portion of your android project should automatically sync with your backend
portion.
Problem may arise if automatic synchronization is off. So you can sync project with gradle
in upper portion of Android Studio. Then it will be able to detect your JAVA POJO classes in your backend.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.