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

  • Home
  • SEARCH
  • 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 6366645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:26:50+00:00 2026-05-25T00:26:50+00:00

This is the manifest file <?xml version=1.0 encoding=utf-8?> <manifest xmlns:android=http://schemas.android.com/apk/res/android package=net.learn2develop.SMSMessaging android:versionCode=1 android:versionName=1.0> <uses-sdk

  • 0

This is the manifest file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="net.learn2develop.SMSMessaging"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="10" />
    <uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
    <uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".SMS"
                  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>

This is the XML file (main.xml)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="Enter the phone number of recipient"
        />     
    <EditText 
        android:id="@+id/txtPhoneNo"  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"        
        />
    <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"         
        android:text="Message"
        />     
    <EditText 
        android:id="@+id/txtMessage"  
        android:layout_width="fill_parent" 
        android:layout_height="150px"
        android:gravity="top"         
        />          
    <Button 
        android:id="@+id/btnSendSMS"  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:text="Send SMS"
        />    
</LinearLayout>

This is the java file (SMS.java):-

package net.learn2develop.SMSMessaging;

import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.telephony.SmsManager;

public class SMS extends Activity 
{
    Button btnSendSMS;
    EditText txtPhoneNo;
    EditText txtMessage;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);        

        btnSendSMS = (Button) findViewById(R.id.btnSendSMS);
        txtPhoneNo = (EditText) findViewById(R.id.txtPhoneNo);
        txtMessage = (EditText) findViewById(R.id.txtMessage);


        btnSendSMS.setOnClickListener(new View.OnClickListener() 
        {
            public void onClick(View v) 
            {                
                String phoneNo = txtPhoneNo.getText().toString();
                String message = txtMessage.getText().toString();                 
                if (phoneNo.length()>0 && message.length()>0) {
                    sendSMS(phoneNo, message);
                } else {
                    Toast.makeText(getBaseContext(), 
                        "Please enter both phone number and message.", 
                        Toast.LENGTH_SHORT).show();
                }
            }
        });        
    } 
    private void sendSMS(String phoneNumber, String message)
    {        
        PendingIntent pi = PendingIntent.getActivity(this, 0,
            new Intent(this, SMS.class), 0);                
        SmsManager sms = SmsManager.getDefault();
        sms.sendTextMessage(phoneNumber, null, message, pi, null);        
    }   
}

The error portion :-

08-26 23:06:41.040: ERROR/AndroidRuntime(411): FATAL EXCEPTION: main
08-26 23:06:41.040: ERROR/AndroidRuntime(411): java.lang.RuntimeException: Unable to start activity ComponentInfo{net.learn2develop.SMSMessaging/net.learn2develop.SMSMessaging.SMS}: java.lang.NullPointerException
08-26 23:06:41.040: ERROR/AndroidRuntime(411):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
08-26 23:06:41.040: ERROR/AndroidRuntime(411):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
08-26 23:06:41.040: ERROR/AndroidRuntime(411):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-26 23:06:41.040: ERROR/AndroidRuntime(411):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
08-26 23:06:41.040: ERROR/AndroidRuntime(411):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-26 23:06:41.040: ERROR/AndroidRuntime(411):     at android.os.Looper.loop(Looper.java:123)
08-26 23:06:41.040: ERROR/AndroidRuntime(411):     at android.app.ActivityThread.main(ActivityThread.java:3683)
08-26 23:06:41.040: ERROR/AndroidRuntime(411):     at java.lang.reflect.Method.invokeNative(Native Method)
08-26 23:06:41.040: ERROR/AndroidRuntime(411):     at java.lang.reflect.Method.invoke(Method.java:507)
08-26 23:06:41.040: ERROR/AndroidRuntime(411):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-26 23:06:41.040: ERROR/AndroidRuntime(411):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-26 23:06:41.040: ERROR/AndroidRuntime(411):     at dalvik.system.NativeStart.main(Native Method)
08-26 23:06:41.040: ERROR/AndroidRuntime(411): Caused by: java.lang.NullPointerException
08-26 23:06:41.040: ERROR/AndroidRuntime(411):     at net.learn2develop.SMSMessaging.SMS.onCreate(SMS.java:31)
08-26 23:06:41.040: ERROR/AndroidRuntime(411):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-26 23:06:41.040: ERROR/AndroidRuntime(411):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
08-26 23:06:41.040: ERROR/AndroidRuntime(411):     ... 11 more
  • 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-25T00:26:51+00:00Added an answer on May 25, 2026 at 12:26 am

    YOu’re getting a NullPointerException at line 31 which is where btnSendSMS.setOnClickListener(

    Probably the view with the id wasn’t found.

    as a workaround add

    if (btnSendSMS != null) {
       btnSendSMS.setOnClickLi......
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I guess something should be done with the Android-Manifest.xml file or something in the
I am trying to implement this example http://www.javacodegeeks.com/2011/02/android-google-maps-tutorial.html and i have followed exactly all
Hi. I have create a background service application following this tutorial http://androidsourcecode.blogspot.com/2010/10/basic-android-background-service.html . But
I observe unmanaged.dll files having a unmanaged.dll.manifest file tagging along. On opening this files
I came across the following two lines in AndroidMenifest.xml file of my android application:
I've created a WebView-based application according to http://developer.android.com/resources/tutorials/views/hello-webview.html Although I did exactly what was
when I tried to add android:installLocation=auto in my AndroidManifest.xml file I found the following
This code installs gems into your project based on a gem manifest. Why does
I am getting this Error while executing my android application : Host is unresolved:
I have a problem when I load interactive SWF file in android emulator. I

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.