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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:04:49+00:00 2026-05-26T11:04:49+00:00

I am trying to run to Android code using an AsyncTask . However it

  • 0

I am trying to run to Android code using an AsyncTask . However it is resulting in many exceptions. I am not able to remove these exceptions. The application stops unexpectedly.

Can someone help me ?

Here is my Android code :

     package com.example;
     import java.net.SocketException;
     import org.ksoap2.SoapEnvelope;
     import org.ksoap2.serialization.SoapObject;
     import org.ksoap2.serialization.SoapPrimitive;
     import org.ksoap2.serialization.SoapSerializationEnvelope; 
     import org.ksoap2.transport.HttpTransportSE;
     import android.app.Activity;
     import android.app.ProgressDialog;
     import android.os.AsyncTask;
     import android.os.Bundle; 
     import android.util.Log;
     import android.view.View;
     import android.view.View.OnClickListener;
     import android.widget.Button;
     import android.widget.EditText;

   public class TeacherLoginActivity extends Activity
    {
    private final String NAMESPACE = "http://tempuri.org/";
    private final String URL = "http://10.0.2.2/loginteacher/Service1.asmx";

    String t_id;
    String password;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            Button signin = (Button) findViewById(R.id.regsubmitbtn);

            signin.setOnClickListener(new OnClickListener() {
                    public void onClick(View v) {


                            EditText etxt_user = (EditText) findViewById(R.id.usereditlog);
                            t_id = etxt_user.getText().toString();
                            EditText etxt_password = (EditText) findViewById(R.id.pwdeditlog);
                            password = etxt_password.getText().toString();


                            new LoginTask().execute();

                    }
            });   
        }

    private String doLogin(String t_id, String password) {

       String res=null;
       final String SOAP_ACTION = "http://tempuri.org/GetLogin";
       final String METHOD_NAME = "GetLogin";     
       SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

       request.addProperty("teacherid", t_id);
       request.addProperty("password",password);
       SoapSerializationEnvelope envelope = new    SoapSerializationEnvelope(SoapEnvelope.VER11);
       envelope.dotNet = true; // Set this variable to true for
                                                               // compatibility with what seems to be the
                                                               // default encoding for .Net-Services.
       envelope.setOutputSoapObject(request);

       System.out.println(request);

       HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);


       try {
              androidHttpTransport.call(SOAP_ACTION, envelope);
              SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
              Log.i("myApp", response.toString());
              System.out.println("response" +response);
              res=response.toString(); 
              System.out.println(res);


       }catch(SocketException ex)
       {
           Log.e("Error : " , "Error on soapPrimitiveData() " + ex.getMessage());
           ex.printStackTrace();
       }
       catch (Exception e) {
           Log.e("Error : " , "Error on soapPrimitiveData() " + e.getMessage());
               e.printStackTrace();
       }

       return res;

       }


    private class LoginTask extends AsyncTask<Void, Void, Void> {

        private final ProgressDialog dialog = new ProgressDialog(
                TeacherLoginActivity.this);

        protected void onPreExecute() {

                this.dialog.setMessage("Logging in...");
                this.dialog.show();

        }


        protected Void doInBackground(final Void... unused) {

            String auth=doLogin(t_id,password);
            System.out.println(auth);

            return null; // don't interact with the ui!
        }


        protected void onPostExecute(Void result) 
        {

                if (this.dialog.isShowing()) {
                this.dialog.dismiss();
                                             }  

         }

      }

       }

My logcat : 

   10-27 20:03:11.329: ERROR/Error :(493): Error on soapPrimitiveData()  Permission denied
   10-27 20:14:31.458: ERROR/Error :(576): Error on soapPrimitiveData() Permission denied
   10-27 20:14:31.458: WARN/System.err(576): java.net.SocketException: Permission denied
   10-27 20:14:31.498: WARN/System.err(576):     at       org.apache.harmony.luni.platform.OSNetworkSystem.createStreamSocketImpl(Native Method)
   10-27 20:14:31.498: WARN/System.err(576):     at org.apache.harmony.luni.platform.OSNetworkSystem.createStreamSocket(OSNetworkSystem.java:186)
   10-27 20:14:31.498: WARN/System.err(576):     at  org.apache.harmony.luni.net.PlainSocketImpl.create(PlainSocketImpl.java:265) 
   10-27 20:14:31.498: WARN/System.err(576):     at  java.net.Socket.checkClosedAndCreate(Socket.java:873)
   10-27 20:14:31.498: WARN/System.err(576):     at java.net.Socket.connect(Socket.java:1020)
   10-27 20:14:31.498: WARN/System.err(576):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:62)
   10-27 20:14:31.498: WARN/System.err(576):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:88)

    10-27 20:14:32.869: ERROR/WindowManager(576):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    10-27 20:14:32.869: ERROR/WindowManager(576):     at com.and roid.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    10-27 20:14:32.869: ERROR/WindowManager(576):     at dalvik.system.NativeStart.main(Native Method)
    10-27 20:14:34.188: INFO/Process(576): Sending signal. PID: 576 SIG: 9
  • 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-26T11:04:50+00:00Added an answer on May 26, 2026 at 11:04 am

    You probably need to add permissions in your XML file.

    Something like:

    <uses-permission
            android:name="android.permission.INTERNET" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to run this code in android using eclips IDE. int maxrow=0;
I'm trying to write a code that can run on Android 1.5 and 2.0.1,
I'm using Eclipse to code Java (for Android) and I'm trying to debug the
Hello i have created a sample application in android using eclipse IDE my code
I can run this code in Android app (using PhoneGap adn jQuery Mobile) but
Im trying to run a VOIP call using built in SIP on android 3.1.
I'm trying to develop an Audio Capture application using the AudioRecord class from android
I'm trying to use custom notifications in my Android application using Google's sample from
I am trying to run android instrumentation Junit test using command line.I am using
When trying to run an Eclipse Dynamic Web Project under a Tomcat setup using

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.