This question already has an answer here:
I have a function that's saving a string, and I want that this function will run another one. this is my code:
public static String IsLoggedIn() {
new Thread(new Runnable() {
@Override
public void run() {
String cookies = CookieManager.getInstance().getCookie(getUrl);
BasicCookieStore lCS = getCookieStore(cookies, "klh-dev.com");
HttpContext localContext = new BasicHttpContext();
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.setCookieStore(lCS);
localContext.setAttribute(ClientContext.COOKIE_STORE, lCS);
HttpGet get = new HttpGet("http://klh-dev.com/lehava/lehava/system/isloggedin.php");
try {
result=httpclient.execute(get,localContext);
response_str = EntityUtils.toString(result.getEntity());
System.out.println(response_str);
UpdateMenu(); //This is the line I'm trying to add
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
return response_str;
}
public void UpdateMenu() {
mTitle = mDrawerTitle = getTitle();
mPlanetTitles = getResources().getStringArray(R.array.planets_array);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.left_drawer);
if (isUserLoggedIn.equals("0")) {
Arrays.copyOfRange(mPlanetTitles, 0, 2);
}
mDrawerList.setAdapter(new ArrayAdapter<String>(this,
R.layout.drawer_list_item, mPlanetTitles));
}
In the try I'm trying to add UpdateMenu();
but it's not working. The error is: Cannot make a static reference to the non-static method UpdateMenu() from the type MainActivity
Thank you for helping!
0 comments:
Post a Comment