-2
我有两个一级的API调用。另一个是为api类获取价值。函数返回值为null。我如何从返回值结果中获得价值。 这里是功能类: -从函数获得空值返回值
Jsondeletenote js = new Jsondeletenote(context);
String retn = js.deletsubmitData();
Log.d("calllllllllll render", "helo"+retn);
// retn value coming null
这里是API类
public String deletsubmitData() {
try {
new Thread(new Runnable() {
@Override
public void run() {
try {
Looper.prepare();
Log.d("looper", "-->>>>");
try {
isAuthorized = isAuthenticated();
} catch (Exception e) {
Log.e("Exception ==> ", e.toString());
}
MHandler.post(new Runnable() {
@Override
public void run() {
try {
if(isAuthorized){
if(AuthenticationResultJSONObject!=null){
Day1 = AuthenticationResultJSONObject.getString("Day");
String Tomorrow = AuthenticationResultJSONObject.getString("Tomorrow");
String Week = AuthenticationResultJSONObject.getString("Week");
}
}
else
{
///Toast.makeText(context, "Loing unsuccessfull, please try again !", Toast.LENGTH_SHORT).show();
}
}
catch (Exception e)
{
e.printStackTrace();
Log.e("Exception 146==> ", e.toString());
}
finally
{
//dialog.cancel();
}
}
});
} catch (Exception e) {
Log.e("Exception 153==> ", e.toString());
}
}
}).start();
} catch (Exception e) {
Log.e("Exception 159==> ", e.toString());
}
return Day1;
}
public boolean isAuthenticated()
{
isAuthorized = false;
final String url="www.abcd.com";
try {
AuthenticationResultJSONObject = new JSONObject(doFetchDataFromWebService_Simple_OnlyJSONResponse(url));
Log.v("Online", "User json array === "+AuthenticationResultJSONObject);
else
{
MHandler.post(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
Toast.makeText(context, "Please check your internet connection and try again.", Toast.LENGTH_SHORT).show();
}
});
}*/
}
catch(Exception e){
e.getMessage();
}
finally{
if(AuthenticationResultJSONObject!=null){
isAuthorized = true;
}
else
{
isAuthorized=false;
}
}
return isAuthorized;
}
你能帮我解释一下代码吗?如何应用回调方法? –