i am a totally new guy around here and i dont know whether its the right place to ask my silly doubts…but please help me guys…i coded a simple sms sending programe and its showing runtime errror..i dont knw how to debug it..plz help
package com.smsProject;
import android.app.Activity;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class SmsProjectActivity extends Activity implements OnClickListener {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
buttonSend=(Button)findViewById(R.id.send);
buttonSend.setOnClickListener(this);
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String msg=editTextmessage.getText().toString();
String num=editTextnumber.getText().toString();
SmsManager sms=SmsManager.getDefault();
sms.sendTextMessage(num,null, msg,null,null);
editTextmessage.setText("");
editTextnumber.setText("");
}
}
my main.xml file is
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" android:background="@drawable/jibin">
<EditText
android:id="@+id/msg"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:hint="Enter the message">
<requestFocus />
</EditText>
<EditText
android:id="@+id/num"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text|textPersonName" android:hint="Enter a number"/>
<Button
android:id="@+id/send"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Send" />
</LinearLayout>
my exception catlog is
01-31 20:40:43.587: W/dalvikvm(1593): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
01-31 20:40:43.607: E/AndroidRuntime(1593): FATAL EXCEPTION: main
01-31 20:40:43.607: E/AndroidRuntime(1593): java.lang.NullPointerException
01-31 20:40:47.936: W/InputManagerService(71): Got RemoteException sending setActive(false) notification to pid 1593 uid 10038
01-31 20:43:45.129: D/SntpClient(71): request time failed: java.net.SocketException: Address family not supported by protocol
01-31 20:48:45.130: D/SntpClient(71): request time failed: java.net.SocketException: Address family not supported by protocol
01-31 20:49:43.546: W/dalvikvm(1638): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
01-31 20:49:43.556: E/AndroidRuntime(1638): FATAL EXCEPTION: main
01-31 20:49:43.556: E/AndroidRuntime(1638): java.lang.NullPointerException
01-31 20:49:47.227: W/InputManagerService(71): Got RemoteException sending setActive(false) notification to pid 1638 uid 10038
01-31 20:53:45.137: D/SntpClient(71): request time failed: java.net.SocketException: Address family not supported by protocol
01-31 20:58:45.151: D/SntpClient(71): request time failed: java.net.SocketException: Address family not supported by protocol
01-31 21:03:45.156: D/SntpClient(71): request time failed: java.net.SocketException: Address family not supported by protocol
01-31 21:08:45.167: D/SntpClient(71): request time failed: java.net.SocketException: Address family not supported by protocol
01-31 21:13:45.177: D/SntpClient(71): request time failed: java.net.SocketException: Address family not supported by protocol
01-31 21:18:45.178: D/SntpClient(71): request time failed: java.net.SocketException: Address family not supported by protocol
01-31 21:23:45.187: D/SntpClient(71): request time failed: java.net.SocketException: Address family not supported by protocol
01-31 21:28:45.187: D/SntpClient(71): request time failed: java.net.SocketException: Address family not supported by protocol
01-31 21:33:45.196: D/SntpClient(71): request time failed: java.net.SocketException: Address family not supported by protocol
01-31 21:38:45.199: D/SntpClient(71): request time failed: java.net.SocketException: Address family not supported by protocol
01-31 21:43:45.207: D/SntpClient(71): request time failed: java.net.SocketException: Address family not supported by protocol
01-31 21:48:45.211: D/SntpClient(71): request time failed: java.net.SocketException: Address family not supported by protocol
01-31 21:52:31.657: W/dalvikvm(1758): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
01-31 21:52:31.667: E/AndroidRuntime(1758): FATAL EXCEPTION: main
01-31 21:52:31.667: E/AndroidRuntime(1758): java.lang.NullPointerException
01-31 21:53:45.216: D/SntpClient(71): request time failed: java.net.SocketException: Address family not supported by protocol
Please post the runtime exception from logcat. Hard to say without that, but my guess is that you haven’t requested the appropriate permissions, try adding this to the top-level
manifestnode of your manifest xml file: