Problem while sending SMS- Could not connect to cilent socket : connection refused.

by javame_android » Wed, 31 Dec 2008 14:07:03 GMT


Sponsored Links
 Hi,

I am trying to write a simple application for sending SMS. In that one
needs to enter a number and after fetching that number from the
textbox sms should be send to that number. I have tried to implement
that code on emulator. It gives could not connect to client socket:
Connection refused. What is it? Am I missing something?

Hope to get a reply soon.

Thanks & Regards
Sunil
--~--~---------~--~----~------------~-------~--~----~



Problem while sending SMS- Could not connect to cilent socket : connection refused.

by javame_android » Wed, 31 Dec 2008 14:44:00 GMT


 Hi,

Thanks for replying.

You are saying to add permission for internet but I am not using
anything related to internet. I have written a simple application that
just sends message. That is working fine but this problem has come
when trying to implement with GUI. I have added the permission for
sending sms. I want to send SMS on the click event of button. When I
click the button then it gives the error as could not connect to
client socket : connection refused.

Any help would be appreciated.

Thanks & Regards
Sunil




--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Problem while sending SMS- Could not connect to cilent socket : connection refused.

by javame_android » Wed, 31 Dec 2008 14:56:55 GMT


 package com.android.hello;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.telephony.gsm.SmsManager;
import android.text.Editable;

public class HelloAndroid extends Activity
{
    final String textMsg = "Hello, Message sent on Click";

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);
        final SmsManager smsManager = SmsManager.getDefault();
        Button button = (Button)findViewById(R.id.ok);
        button.setOnClickListener(new Button.OnClickListener()
        {
                public void onClick(View arg0)
                {
                        EditText editText = (EditText)findViewById(R.id.entry);
                Editable tPhone = editText.getText();
                String numToSendMsg = tPhone.toString();
                smsManager.sendTextMessage(numToSendMsg, null,
textMsg, null, null);
                }
        });
    }
}

Above is the code that I am trying to run. Everything is working fine,
GUI is displayed properly. The problem only comes when I click on
button. I am very new to Android so not getting where I am getting
wrong.

Thanks
Sunil


--~--~---------~--~----~------------~-------~--~----~



Problem while sending SMS- Could not connect to cilent socket : connection refused.

by javame_android » Wed, 31 Dec 2008 16:52:56 GMT


 Hi,

Did what you said but no success. Still the same problem GUI displayed
properly but after entering number in the textbox and pressing the
button it gives on ddms console as could not connect to client
socket : connection refused.

By the way I did what you said but I dont think for sending sms one
has to write uses-permission for receiving sms.
Anyways thanks.

Is there anybody who has encountered same error and can help me out.

Thanks & Regards
Sunil




--~--~---------~--~----~------------~-------~--~----~



Problem while sending SMS- Could not connect to cilent socket : connection refused.

by javame_android » Thu, 01 Jan 2009 13:33:46 GMT


 Hi,

This was solved by calling another activity. It means UI displayed in
one activity and sms sending task achieved in another activity. I dont
know whether this is the way or not but it removed this error.

Sunil





--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Fwd: Slider Drawer Problem - disappearing slider

Hi there,

I am currently working on a video editing view for my app and I wanted to
include a sliding drawer with different video editing functions, but I
already ran into a problem with the slider itself because when tap it to
open, it opens fine, but when I tap it a second time to close it again, it
disappears entirely (the slider image moves off the screen). As I haven't
found anything similar I am hoping that someone here can help. Thank you in
advance.

Here is what I do to create the slider:
<RelariveLayout>
 ...

 <SlidingDrawer
     android:id="@+id/drawer"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
 android:orientation="horizontal"
     android:handle="@+id/handle"
     android:content="@+id/content">

     <ImageView
         android:id="@id/handle"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:src="@drawable/slider_handle"
         android:layout_centerVertical="true"
         android:layout_centerHorizontal="true"
         />

     <LinearLayout
         android:id="@id/content"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent">
        <!-- CONTENT -->
     </LinearLayout>
 </SlidingDrawer>
</RelativeLayout>

-- 

2. How to access build type [release/debug] in java/xml code at run time

I want to access the build type [release/debug] in java code and xml
file to enable or disable the particular feature at the run time.

Please let me know if we have any environment variable defined for it
which can be accessed in java code and in xml file also.

-- 

3. Free trial and payed apps... How to switch from...

4. Loading images in android

5. Free trial and payed apps... How to switch from...

6. Bringing activity to front -Urgent help

7. Leaked Window changing orientation with SubMenu