Loading...

Android - Simple Sending SMS

View: 557    Dowload: 0   Comment: 0   Post by: daii   Category: Mobile applications   Fields: Game - Entertainment

Download  android-simple-sending-sms.zip (416.53 KB)

You need to Sign In to download the file android-simple-sending-sms.zip
If you do not have an account then Sign up for free here

In this tutorial we will try to create a Simple Sending SMS using Android. This tutorial is only an example for sending an SMS, it does not contain the receiving message yet. Android is a mobile operating system developed by Google. It used in several gadget like smartphone, tablet, and even television. Android is open source to developers who has an interest in developing mobile apps. It also provide an adaptive framework that allow the developer to develop an apps in a simpler way. So let's now do the coding...

Getting Started:

First you will have to download & install the Android Development IDE (Android Studio or Eclipse). Android Studio is an open source development feel free to develop your things.

Here's the link for the Android Studio https://developer.android.com/studio/index.html.

Layout Design

We will now create the design for the application, first locate the layout file called activity_main.xml, this is the default name when create a new activity. Then write these codes inside your layout file.


 
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <RelativeLayout xmlns:android="<a href="http://schemas.android.com/apk/res/android"
  3. " rel="nofollow">http://schemas.android.com/apk/res/android"
  4. </a> xmlns:app="<a href="http://schemas.android.com/apk/res-auto"
  5. " rel="nofollow">http://schemas.android.com/apk/res-auto"
  6. </a> xmlns:tools="<a href="http://schemas.android.com/tools"
  7. " rel="nofollow">http://schemas.android.com/tools"
  8. </a> android:layout_width="match_parent"
  9. android:layout_height="match_parent"
  10. tools:context="com.razormist.sendsmsapp.MainActivity">
  11.  
  12. <EditText
  13. android:id="@+id/et_contact"
  14. android:layout_height="wrap_content"
  15. android:layout_width="match_parent"
  16. android:inputType="number"
  17. android:hint="Contact Number"/>
  18.  
  19. <EditText
  20. android:id="@+id/et_message"
  21. android:layout_height="250dp"
  22. android:layout_width="match_parent"
  23. android:hint="Message"
  24. android:inputType="textMultiLine"
  25. android:gravity="left"
  26. android:layout_below="@+id/et_contact"/>
  27.  
  28. android:id="@+id/btn_send"
  29. android:layout_height="wrap_content"
  30. android:layout_width="wrap_content"
  31. android:layout_below="@+id/et_message"
  32. android:layout_centerHorizontal="true"
  33. android:text="send"/>
  34.  
  35. </RelativeLayout>

Android Manifest File

The Android Manifest file provides essential information about your app to the Android system in which the system must required before running the code. It describe the overall information about the application. It contains some libraries that needed to access the several method within the app.


 
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="<a href="http://schemas.android.com/apk/res/android"
  3. " rel="nofollow">http://schemas.android.com/apk/res/android"
  4. </a> package="com.razormist.sendsmsapp">
  5.  
  6. <uses-permission android:name="android.permission.SEND_SMS" />
  7. <application
  8. android:allowBackup="true"
  9. android:icon="@mipmap/ic_launcher"
  10. android:label="@string/app_name"
  11. android:roundIcon="@mipmap/ic_launcher_round"
  12. android:supportsRtl="true"
  13. android:theme="@style/AppTheme">
  14. <activity android:name=".MainActivity"
  15. android:configChanges="orientation"
  16. android:screenOrientation="portrait">
  17. <intent-filter>
  18. <action android:name="android.intent.action.MAIN" />
  19.  
  20. <category android:name="android.intent.category.LAUNCHER" />
  21. </intent-filter>
  22. </activity>
  23. </application>
  24. </manifest>

The Main Function

This code contains the main function of the application. This code will sent some sms data to the number that input, this will only work when there is an available network . To start with first locate your MainActivity java file and open it, then write these variable inside the MainActivity class.


 
  1. Button btn_send;
  2. EditText et_contact, et_message;

Then write these method to make the code work correctly.


 
  1. private void PermissionToConnect(){
  2. if(ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.SEND_SMS) != PackageManager.PERMISSION_GRANTED){
  3. if(ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, Manifest.permission.SEND_SMS)){
  4. ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.SEND_SMS}, 1);
  5. }else{
  6. ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.SEND_SMS}, 1);
  7. }
  8. }
  9.  
  10. }
  11.  
  12. @Override
  13. public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
  14. if(requestCode == 1) {
  15. if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
  16. if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.SEND_SMS) == PackageManager.PERMISSION_GRANTED) {
  17. Toast.makeText(this, "Access", Toast.LENGTH_SHORT).show();
  18. }
  19. } else {
  20. Toast.makeText(this, "Denied", Toast.LENGTH_SHORT).show();
  21. }
  22. }
  23. }

Finally, initialize the require methods inside the onCreate method to run the application.


 
  1. btn_send = (Button)findViewById(R.id.btn_send);
  2. et_contact = (EditText)findViewById(R.id.et_contact);
  3. et_message = (EditText)findViewById(R.id.et_message);
  4.  
  5. PermissionToConnect();
  6.  
  7. btn_send.setOnClickListener(new View.OnClickListener() {
  8. @Override
  9. public void onClick(View v) {
  10. String number = et_contact.getText().toString();
  11. String message = et_message.getText().toString();
  12.  
  13. try{
  14. SmsManager smsManager = SmsManager.getDefault();
  15. smsManager.sendTextMessage(number, null, message, null, null);
  16. Toast.makeText(MainActivity.this, "Sent", Toast.LENGTH_SHORT).show();
  17. }catch (Exception e){
  18. Toast.makeText(MainActivity.this, "Sending Failed", Toast.LENGTH_SHORT).show();
  19. }
  20.  
  21. }
  22. });

Try to run the app and see if it worked.

There you have it we have created a Simple Sending SMS using Android. I hope that this tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!!!

Android - Simple Sending SMS

Learn on how to create a Simple Sending SMS using Android. This tutorial is only an example for sending an SMS, it does not contain the receiving message yet. Android is a mobile operating system developed by Google. It used in several gadget like smartphone, tablet, and even television. Android is open source to developers who has an interest in developing mobile apps. It also provide an adaptive framework that allow the developer to develop an apps in a simpler way.

Posted on 17-04-2018 

Comment:

To comment you must be logged in members.

Files with category

  • Android - Simple Image Capture

    Android - Simple Image Capture

    View: 644    Download: 0   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    Learn on how to create a Simple Image Capture using Android. This simple application can be used to any system that needed the information about the location of the user. The android is an open source operating system it's free and user friendly to...

  • Android - Simple Video Player

    Android - Simple Video Player

    View: 497    Download: 0   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    Learn on how to create a Simple Video Player using Android. This simple application can be use in viewing some videos. The android is an open source operating system it's free and user friendly to mobile developers. Android is available to any...

  • An Experience about Using Webview in Android Studio 3.0

    An Experience about Using Webview in Android Studio 3.0

    View: 285    Download: 0   Comment: 0

    Category: Android     Fields: Other

    I am blogging on ngocminhtran.com (using WordPress platform). Like most websites, I want to write an Android application to help viewers have a lot of great experiences with my blog.

  • Android - Simple Sending SMS

    Android - Simple Sending SMS

    View: 557    Download: 0   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    Learn on how to create a Simple Sending SMS using Android. This tutorial is only an example for sending an SMS, it does not contain the receiving message yet. Android is a mobile operating system developed by Google. It used in several gadget like...

  • Bomb Explode! (An Android App Strategy Game)

    Bomb Explode! (An Android App Strategy Game)

    View: 510    Download: 0   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    This android app named Bomb Explode! is a capstone project that I made for a particular school. BOMB EXPLODE! is a Human Versus Computer strategy game. The objective is to eliminate the opponent by blowing up their BOMBS. Each player takes a turn by...

  • GIS App for Flood-Prone and Disease Affected Areas

    GIS App for Flood-Prone and Disease Affected Areas

    View: 496    Download: 1   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    GIS App for Flood-Prone and Disease Affected Areas is one of the capstone project that I have created in a particular school. Features of the application: - Geographic Map - GIS - Flood Prone Map - Urban Map - Search a particular area - Has SQLite...

  • NSO Demographic Application

    NSO Demographic Application

    View: 541    Download: 0   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    This app is entitled NSO Demographic Application that was one of the capstone project/thesis project that I made for a particular school. This app features to provide a demographic survey of the National Statistics Office that will send to the...

  • HandEBook: An IT Portable Book Application

    HandEBook: An IT Portable Book Application

    View: 514    Download: 0   Comment: 0

    Category: Mobile applications     Fields: Game - Entertainment

    This is an android mobile application entitled HandEBook: An IT Portable Book Application was one one of the capstone project that I have made in our clients at Cotabato. We used the Basic4Android software for the frontend and SQLite for the database...

 
File suggestion for you
Loading...
File top downloads
Loading...
Loading...
Codetitle - library source code to share, download the file to the community
Copyright © 2018. All rights reserved. codetitle Develope by Vinagon .Ltd