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

The Archive Base Latest Questions

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

Recently i am developing Android applications what i wanted to do is consume a

  • 0

Recently i am developing Android applications
what i wanted to do is consume a web services
from .net WCF into my application

Here is my Client Code

import java.io.InputStream;<br>
import java.io.InputStreamReader;

import org.apache.http.HttpEntity;<br>
import org.apache.http.HttpResponse;<br>
import org.apache.http.client.methods.HttpGet;<br>
import org.apache.http.impl.client.DefaultHttpClient;<br>
import org.json.JSONObject;<br>

import android.R.string;<br>
import android.os.Bundle;<br>
import android.app.Activity;<br>
import android.view.Menu;<br>
import android.view.View;<br>
import android.widget.TextView;<br>


public class MyPamIndex extends Activity {

    private final static String SERVICE_URI = "http://172.30.2.95:9000/JSON/MyPam.svc";
    private TextView NabVals;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_pam_index);


            NabVals = (TextView)findViewById(R.id.textView2);
    }
    public void OnRefreshClick(View button)
    {
         try {
             // Send GET request to <service>/GetVehicle/<plate>
             DefaultHttpClient httpClient = new DefaultHttpClient();
             HttpGet request = new HttpGet(SERVICE_URI + "/ProductID/" + "1");

             request.setHeader("Accept", "application/json");
             request.setHeader("Content-type", "application/json");

             HttpResponse response = httpClient.execute(request);
             HttpEntity responseEntity = response.getEntity();

             // Read response data into buffer
             char[] buffer = new char[(int)responseEntity.getContentLength()];
             InputStream stream = responseEntity.getContent();
             InputStreamReader reader = new InputStreamReader(stream);
             reader.read(buffer);
             stream.close();

             JSONObject vehicle = new JSONObject(new String(buffer));
             NabVals.setText(vehicle.getString("NabValue"));
             // Populate text fields


         } catch (Exception e) {
             e.printStackTrace();

         }
    }

when i run the apps it have an error
in
HttpResponse response = httpClient.execute(request);
i have search the entire forum but found nothing
i already add my android manifest file but still does not working
please help me

this is my Manifest file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.core.mypam"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-permission android:name="anroid.permission.INTERNET"></uses-permission>
    <uses-sdk
        android:minSdkVersion="7"
        android:targetSdkVersion="16" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.core.mypam.MyPamIndex"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

“http://172.30.2.95:9000&#8221; is not my machine IP but its located on other PC within same LAN
Please help me

  • 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-15T09:17:36+00:00Added an answer on June 15, 2026 at 9:17 am

    You’re making a network request on the UI thread. That is no longer allowed and, and will raise an exception. You need to move your code into an AsyncTask. Google NetworkOnMain for a plethora of examples.

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

Sidebar

Related Questions

I was recently developing an android application where I wanted to display kannada text
I've had the thrill recently of developing web service applications. Most of my experience
Recently I started with developing a JBoss SEAM web application (auction site). So far
I've recently started developing my first serious application which uses a SQL database, and
Recently, I've been developing an open source proxy that has a client and a
I'm developing my first java application using Eclipse. I've recently needed to adjust the
So we have recently started developing applications for the iPad for our company. Unfortunately
I've recently started developing applications for the Blackberry. Consequently, I've had to jump to
My company has recently started developing custom iPhone applications for various clients. One of
I have recently been developing a newsletter for a client of mine. How ever

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.