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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:09:16+00:00 2026-05-20T18:09:16+00:00

package com.rest; import java.io.IOException; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button;

  • 0
package com.rest;
import java.io.IOException;  

import android.app.Activity;  
import android.os.Bundle;  
import android.util.Log;  
import android.view.View;  
import android.widget.Button;  
import android.widget.EditText;  
import android.widget.Toast;

import org.apache.http.client.ClientProtocolException;  
import org.apache.http.client.HttpClient;  
import org.apache.http.client.ResponseHandler;  
import org.apache.http.impl.client.BasicResponseHandler;  
import org.apache.http.client.methods.HttpGet;  
import org.apache.http.impl.client.DefaultHttpClient;  
import android.app.Activity;
import android.os.Bundle;

public class rest extends Activity {
    /** Called when the activity is first created. */

    String URL = "http://sc2.mystreamserver.com:8050/admin.cgi?mode=viewxml";  
       String result = "";  
        String deviceId = "xxxxx" ;  
       final String tag = "Your Logcat tag: ";  
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);




          /** Called when the activity is first created. */  

        callWebService();  

                final EditText txtSearch = (EditText)findViewById(R.id.txtSearch);  
             txtSearch.setOnClickListener(new EditText.OnClickListener(){  
                public void onClick(View v){txtSearch.setText("");}  
             });  

               final Button btnSearch = (Button)findViewById(R.id.btnSearch);  
                btnSearch.setOnClickListener(new Button.OnClickListener(){  
                    public void onClick(View v) {  
                        String query = txtSearch.getText().toString();  


                   }  
               });  

          } // end onCreate()  

           public void callWebService(){  
              HttpClient httpclient = new DefaultHttpClient();  
               HttpGet request = new HttpGet(URL);  
               request.addHeader("username","    "); 
               request.addHeader("pass","   ");  
               ResponseHandler<String> handler = new BasicResponseHandler();  
               try {  
                  result = httpclient.execute(request, handler);  
                } catch (ClientProtocolException e) {  
                    result=e.toString(); 
                } catch (IOException e) {  
                    result=e.toString();  
                }  
                httpclient.getConnectionManager().shutdown();  
               Log.i(tag, result);  
               Toast.makeText(rest.this, result, Toast.LENGTH_SHORT).show();
            } // end callWebService()  

 }

i am not getting the result.plz help to get result….

  • 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-20T18:09:16+00:00Added an answer on May 20, 2026 at 6:09 pm

    Please try this.

    public void callWebService()
    {  
        HttpPost postMethod = new HttpPost("Your Url");
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    
        nameValuePairs.add(new BasicNameValuePair("username","your user name");
        nameValuePairs.add(new BasicNameValuePair("password","your password");
        postMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        DefaultHttpClient hc = new DefaultHttpClient();
    
        HttpResponse response = hc.execute(postMethod);
        HttpEntity entity = response.getEntity();
    
        if (entity != null) 
        {
                InputStream inStream = entity.getContent();
                result= Utility.convertStreamToString(inStream);
                Log.i("---------------- Result",result);
        }
    } // end callWebService()  
    

    public static String convertStreamToString(InputStream is)
    {
       BufferedReader reader = new BufferedReader(new InputStreamReader(is));
       StringBuilder sb = new StringBuilder();
    
       String line = null;
       try 
       {
           while ((line = reader.readLine()) != null) 
           {
               sb.append(line + "\n");
           }
       } 
       catch (IOException e) 
       {
           e.printStackTrace();
       } 
       finally 
       {
           try 
           {
               is.close();
           } 
           catch (IOException e) 
           {
               e.printStackTrace();
           }
       }
       return sb.toString();
    

    }

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

Sidebar

Related Questions

package com.crumbin.tabs; //java package import java.io.IOException; import java.util.ArrayList; import org.json.JSONException; import android.app.Activity; import android.app.AlertDialog;
This is my FragmentListArraySupport.java package com.test.methods; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.app.ListFragment; import android.util.Log;
package com.org.myOxygen.activities; import java.util.Stack; import android.app.Activity; import android.app.ActivityGroup; import android.app.LocalActivityManager; import android.content.Intent; import android.os.Bundle;
I have this code: package com.powergroupbd.timer; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.os.CountDownTimer;
package com.crumbin.tabs; import java.util.ArrayList; import java.util.HashMap; import org.apache.http.client.HttpClient; import android.content.Context; import android.database.Cursor; import android.location.Location;
Code for QuizSplashActivity : package com.androidbook.triviaquiz; import java.text.DateFormat; import java.util.Date; import android.content.Intent; import android.content.SharedPreferences;
I have the following custom event: package com.un.photoManager.events { import flash.events.Event; import mx.collections.ArrayCollection; public
this is my custom dialog class: package com.WhosAround.Dialogs; import com.WhosAround.AppVariables; import com.WhosAround.R; import com.WhosAround.AsyncTasks.LoadUserStatus;
Android kills my service in the package com.net.myspeechservice under some certain scenarios, for example
Please consider the following java source: package com.stackoverflow; public class CondSpeed { private static

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.