I'm working with a simple function that I make to do an HTTP friend request that I call from another static reference. The problem is that the fragment system that google provides (Tab Navigator Activity) the prebuild code does not allow me to use a non-static method in there.
The code which I call the method
enviarsolicitud(param1,param2);
This is the code of the void that I say
private static void enviarsolicitud(final String idadder, final String idadded)
{
class EnviarSolicitudClass extends AsyncTask<String,Void,String>
{
@Override
protected void onPreExecute()
{
super.onPreExecute();
System.out.println("enter");
}
@Override
protected void onPostExecute(String s)
{
super.onPostExecute(s);
if(s.contains("friendrequest")){
String[] friendrequest = s.split(":");
System.out.println(friendrequest[0] + " " + friendrequest[1]);
}
else if (s.contains("friendrequestcant"))
{
}
else
{
}
}
@Override
//En segon pla
protected String doInBackground(String... params)
{
HashMap<String,String> dades = new HashMap<>();
dades.put("idadder",params[0]);
dades.put("idadded",params[1]);
RegisterUserClass ruc = new RegisterUserClass();
String resultat = ruc.sendPostRequest("http://www.myurl.net/friend.php",dades);
return resultat;
}
}
EnviarSolicitudClass esc = new EnviarSolicitudClass();
esc.execute(idadder,idadded);
}
I don't know a lot about non-static and static but the problem is that google use static methods for the prebuilded activity. Do you recommend to use static for this type of voids? I always use non-static methods because static is limited a lot