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 8904295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:05:36+00:00 2026-06-15T02:05:36+00:00

I have a problem! I have a connection with a php page to connect

  • 0

I have a problem! I have a connection with a php page to connect with database and the method works fine on Froyo, but doesn’t work on newer versions of Android. What is the problem?

        public static String interact(String request){
            String result="test";
        String site = "http://xxxx.net:nnn/xxx";
        URL url = new URL(site);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();

        connection.setRequestMethod("POST");
        connection.setDoOutput(true);
        connection.connect();

        OutputStreamWriter wr = new OutputStreamWriter(connection.getOutputStream());
        wr.write(request);
        wr.flush();
        wr.close();

        Scanner in = new Scanner(connection.getInputStream());
        while(in.hasNextLine())
        result+=in.nextLine();
        connection.disconnect();
        return result;

    }
    catch (UnknownHostException e) {
        return e.getMessage();
    } catch (IOException ex) {
        return ex.getMessage();
    }
    catch (Exception ex){
        return ex.getMessage();
    }

}   

I need to send data and get response, but it just gives me null on newer Android than 2.2.

  • 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-06-15T02:05:41+00:00Added an answer on June 15, 2026 at 2:05 am

    you are running Network Request on main thread.

    Android >=3.0 does not alow this. you need to use AsyncTask to call Network Request

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with the binding of the below parameter. The connection works
My problem involves checking if I have a valid database connection before reading from
SQL/PHP query works in PHPmyAdmin but not the site. I notice that many have
I have a php page that requires a few queries from a database. So
I have a strange problem on ipv6 connection. I write down a simple client
I am constructing a simple login php page. The problem is, whatever I put
I have a problem with checking if the username exist. It works if it
I have a html page that calls a php object to get some data
I have 2 connection database (MySQL) in different host like this: //database 1 $dbhost='localhost';
I am trying to create a web page using php. The problem is that

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.