Jump to content

TextBin Online

TextBin is a website where you can store any text online for easy sharing.
Buy now
Info
  • Welcome to PhCyber
  • Explore and Enjoy Browsing!
  • Lots of useful topics
  • Stay active and receive prizes
SuperVegita1

Sms Message Sender Android Java

Recommended Posts

package com.example.sendsms;  

  

import android.os.Bundle;  

import android.app.Activity;  

import android.app.PendingIntent;  

import android.content.Intent;  

import android.telephony.SmsManager;  

import android.view.Menu;  

import android.view.View;  

import android.view.View.OnClickListener;  

import android.widget.Button;  

import android.widget.EditText;  

import android.widget.Toast;  

  

public class MainActivity extends Activity {  

  

    EditText mobileno,message;  

    Button sendsms;  

    @Override  

    protected void onCreate(Bundle savedInstanceState) {  

        super.onCreate(savedInstanceState);  

        setContentView(R.layout.activity_main);  

          

        mobileno=(EditText)findViewById(R.id.editText1);  

        message=(EditText)findViewById(R.id.editText2);  

        sendsms=(Button)findViewById(R.id.button1);  

          

    //Performing action on button click  

        sendsms.setOnClickListener(new OnClickListener() {  

              

            @Override  

            public void onClick(View arg0) {  

                String no=mobileno.getText().toString();  

                String msg=message.getText().toString();  

                  

                //Getting intent and PendingIntent instance  

                Intent intent=new Intent(getApplicationContext(),MainActivity.class);  

                PendingIntent pi=PendingIntent.getActivity(getApplicationContext(), 0, intent,0);  

                  

                //Get the SmsManager instance and call the sendTextMessage method to send message  

                SmsManager sms=SmsManager.getDefault();  

                sms.sendTextMessage(no, null, msg, pi,null);  

                  

                Toast.makeText(getApplicationContext(), "Message Sent successfully!",  

                    Toast.LENGTH_LONG).show();  

            }  

        });  

    }  

  

    @Override  

    public boolean onCreateOptionsMenu(Menu menu) {  

        // Inflate the menu; this adds items to the action bar if it is present.  

        getMenuInflater().inflate(R.menu.activity_main, menu);  

        return true;  

    }  

      

}  

 

//Android manifest Permission

 

 //   <uses-permission android:name="android.permission.SEND_SMS"/>  

    

  //  <uses-permission android:name="android.permission.RECEIVE_SMS"/>  

 

//Automatic Send Message Or Automatic nakaw load code Pm me

 

Share this post


Link to post
Share on other sites
Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




General Chat

General Chat

Please enter your display name

×
×
  • Create New...