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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:15:40+00:00 2026-06-05T16:15:40+00:00

In my app i have access to web server. It works fine in Some

  • 0

In my app i have access to web server. It works fine in Some phones but while testing in Samsung Galaxy
Model No – GT-S5830i
Android Version – 2.3.6

it keeps on showing Unknown host exception. I have checked the url from browser its working fine.

private void submitUploadData(String url ,Map<String, String> param) throws IOException 
{  
    URL siteUrl;
    try {
        siteUrl = new URL(url); 
    HttpURLConnection conn = (HttpURLConnection) siteUrl.openConnection();
    conn.setRequestMethod("POST");
    conn.setDoOutput(true);
    conn.setDoInput(true);

    DataOutputStream out = new DataOutputStream(conn.getOutputStream());

    Set getkey = param.keySet();
    Iterator keyIter = getkey.iterator();
    String content = "";
    for(int i=0; keyIter.hasNext(); i++) {
        Object key = keyIter.next();
        if(i!=0) {
            content += "&";
        }
        content += key + "=" +  param.get(key);
    } 
    out.writeBytes(content.trim()); 
    out.flush();
    out.close();
    BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); 
    String line = "";
    while((line=in.readLine())!=null) {
        System.out.println(line);
    }
    in.close();  
    //Intent home = new Intent(SyncHttp.this,TimeAndExpensesSKActivity.class);
    //startActivity(home);
    db.updateTimeExported(1);
    db.updateExpensesExported(1);
    db.close();
    db.close(); 

    if(db.getLogCount()==0){ 
            db.insertSyncDateDetails(getDateandTime());}
            else{
            db.updateSyncDateDetails(1, getDateandTime());}  


    } catch (MalformedURLException e) { 
        e.printStackTrace();
    }
    this.setResult(FINISH_RESULT);
    db.close();
}

I have already added permissions

 <uses-permission android:name="android.permission.INTERNET" />
 <uses-permission android:name="android.permission.CAMERA" />
 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
 <uses-permission android:name="android.permission.READ_PHONE_STATE"/> 

I am really confused why this exception occurring.

Thanks for your help guys.

  • 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-05T16:15:41+00:00Added an answer on June 5, 2026 at 4:15 pm

    My app did this too. This usually caused by unstable network connection. What I did was catching this UnknownHostException and modify the code in a way that if UnknownHostException happened, I try to re-fetch the URL again, after several miliseconds sleep.

    The basic algorithm is something like this:

    private void submitUploadData(String url ,Map<String, String> param) throws IOException 
    {  
        URL siteUrl;
        boolean isDataSubmitted = false;
        while(!isDataSubmitted){
            try {
                //do your complicated http process
                isDataSubmitted = true;
            } catch(UnknownHostException uhe){
                e.printStackTrace();
            } catch (MalformedURLException e) { 
                e.printStackTrace();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a simple web app in PHP that needs to have write access
I have a web application that creates directories. The application works fine when creating
I have a application running on our server (it works fine on my computer
I have a .net v4 web app which uses impersonation as our web server
I have a web app in a subdomain, where I want to uptain access
I'm writing an app, and in many situations need to have direct access to
I have an app which access an app folder on a per user basis.
We have an app that needs to access network resources. It's written in VB.Net.
How do I access hidden fields in angular? I have an app, where I
I have a file as documentRoot/app/webroot/myFile.php I need to be able to access this

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.