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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:26:32+00:00 2026-05-26T21:26:32+00:00

package com.android.SMStest; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.telephony.SmsManager; import android.view.View; import android.widget.Button;

  • 0
package com.android.SMStest;

import android.app.Activity;

import android.content.Context;

import android.os.Bundle;
import android.telephony.SmsManager;

import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.telephony.TelephonyManager;
import android.widget.TextView;

public class SMStestActivity extends Activity {
private TextView txtPhoneNo;
private EditText txtMessage;
private Button btnSendSMS;
private EditText smsamount;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    smsamount = (EditText) findViewById(R.id.smsamount);
    btnSendSMS = (Button) findViewById(R.id.btnSendSMS);
    txtMessage = (EditText) findViewById(R.id.txtMessage);
    txtPhoneNo = (TextView) findViewById(R.id.txtPhoneNo);
    TextView textgetLine1Number = (TextView) findViewById(R.id.txtPhoneNo);
    // retrieve a reference to an instance of TelephonyManager
    final TelephonyManager phonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    textgetLine1Number.setText(getLine1Number());

    btnSendSMS.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            String phoneNo = phonyManager.getLine1Number().toString();
            txtPhoneNo.setText(phoneNo);
            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();
        }
    });
}

// ---sends an SMS message to another device---
private void sendSMS(String phoneNumber, String message) {
    int i;
    SmsManager sms = SmsManager.getDefault();
    for (i = 0; i < 10; i++) {
        sms.sendTextMessage(phoneNumber, null, message, null, null);
    }

}

public String getLine1Number() {
    return ((TelephonyManager) getSystemService(TELEPHONY_SERVICE))
            .getLine1Number();
    }
}

I am using this to enable the app I am making to send a certain amount of text messages to the phones MDN to stress test the sms capabilities. The problem I am running into is getting the number the user enters in the UI to actually control how many sms the app sends. The way I have it now will send the set amount of sms set in the programming with for (i = 0; i < 10; i++) {. I need to be able to make this accept what the user enters so they can set their own amount. I have tried it as an integer with private Integer, but the app just force closes when you click the send sms button. I have tried to use getText().toString(), but it keeps telling me to set it as an integer. Any ideas to help an android newbie out?

  • 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-26T21:26:33+00:00Added an answer on May 26, 2026 at 9:26 pm

    You need to parse the string, so just change:

    for (i = 0; i < 10; i++) {
    

    to:

    int amount = 10; // just making 10 the default if the EditText has an invalid value
    try {
        amount = Integer.parseInt(smsamount.getText().toString());
    }
    catch (NumberFormatException) {}
    
    for (i = 0; i < amount; i++) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

package com.example.android.home; import android.app.Activity; import android.os.Bundle; import android.widget.*; import android.view.*; public class HomeActivity extends
package com.Project_recording; import java.io.File; import java.io.IOException; import android.app.Activity; import android.media.MediaPlayer; import android.media.MediaRecorder; import android.os.Bundle;
I got the following code inside my templateApp.java: package com.android.templateApp; import android.app.Activity; import android.os.Bundle;
package com.android.project; import android.app.Activity; import android.os.Bundle; import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE;
Hy!! I have a problem with the progressdialog. My used code: package com.android.skiptvad; import
The error I'm receiving is listed here . That's my HibernateUtil.java package com.rosejapan; import
My Java application has got a package structure similar to this: src/com/name/app src/com/name/app/do src/com/name/utils/db
I want to read (only) records from data/data/com.android.providers.telephony/databases/mmssms.db (I know no official API, etc.
For the Hello World example in android.com , the package name is package com.example.helloandroid;
02-18 00:02:08.432: ERROR/PackageManager(57): Package com.example.brown requires unavailable shared library com.google.android.maps; failing! I got this

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.