Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6045507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:07:57+00:00 2026-05-23T07:07:57+00:00

I am new in Android. I am trying to make an RPC to fetch

  • 0

I am new in Android. I am trying to make an RPC to fetch data from PHP and get in JSON format. Everything goes fine but I am not getting any data as response. Bellow is my android code

Android Code

try{
    HttpClient httpClient = new DefaultHttpClient();


    JSONObject jsonRequest = new JSONObject(); 
    jsonRequest.put("id", 0); 
    jsonRequest.put("method", "getData"); 


    HttpEntity entity = new StringEntity(jsonRequest.toString()); 
    HttpPost request = new HttpPost("http://121.247.130.30:8080/test/TestJava.php");
    request.setEntity(entity); 
    HttpResponse response = httpClient.execute(request); 
    String temp = EntityUtils.toString(response.getEntity());
    Log.e("Class====","Error:"+temp);
   }
   catch(Exception e){
       Log.e("Class====","Error:"+e.getMessage());
   }

PHP Code

<?php
class TestJava
{
public function getData()  
{  
   $arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
   echo json_encode($arr);
} 
}
?>

Please let me know if anything I did here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:07:57+00:00Added an answer on May 23, 2026 at 7:07 am

    I think you misused entity element. Check what I have in my code:

    StatusLine statusLine = response.getStatusLine();
    
    if(statusLine.getStatusCode() == HttpStatus.SC_OK ){
    
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        response.getEntity().writeTo(out);
        response.getEntity().consumeContent();
        out.close();
        return out.toString();
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to android and I am trying to load huge data which
hey, im new to android development and trying to make my first application. What
Im new to android and i am trying to make a program that outputs
I'm new in android and i'm trying to make an android app to display
I'm new to android development and I'm trying to make an android app that
I'm new at android developing. I'm trying to make a simple drumset app, when
i'm new to android. I'm just trying to make one simple search functionality for
im fairly new to android development, but i'm having some trouble trying to make
I'm new to android and I'm trying to make a simple android program that
Hi I'm new to Android Programming and I'm trying to make a simple program

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.