Hi In the below how to get the group name based on json response from the server.how to display in listview. New is the 1st position and Group is the second position
response
{"groupname":"New"}{"groupname":"Group"}
java
String groupdetails = imService.DispalyGroupDetails(imService.getUsername());
try {
JSONArray JA = new JSONArray(groupdetails);
String[] groupname = new String[JA.length()];
for(int i=0;i<JA.length();i++)
{
groupname[i] = JA.getJSONObject(i).getString("groupname");
}
} catch (Exception e) {
e.printStackTrace();
}
this is php code Here I am getting the output like this
updated
case "DispalyGroupDetails":
$userId = authenticateUser($db, $username, $password);
if ($userId != NULL)
{
if (isset($_REQUEST['username']))
{
$username = $_REQUEST['username'];
$sql = "select Id from users where username='$username' limit 1";
if ($result = $db->query($sql))
{
if ($row = $db->fetchObject($result))
{
$sql = "SELECT g.groupname
FROM `users` u, `friends` f, `group` g
WHERE u.Id=f.providerId and f.providerId=g.providerId
GROUP BY g.id, g.groupname";
$theResult = $db->query($sql);
if ($theResult) {
while( $theRow = $db->fetchObject($theResult))
{
$json_output[]=$theRow;
print(json_encode($json_output));
}
//$out = SUCCESSFUL;
} else {
//$out = FAILED;
}
}
else
{
//$out = FAILED;
}
}
else
{
//$out = FAILED;
}
}
else
{
//$out = FAILED;
}
}
else
{
//$out = FAILED;
}
break;