AA's Quick SMS

This is a discussion on AA's Quick SMS within the LG Ally Hacking / Development forums, part of the LG Ally category; This is my second tutorial. It shows how you can setup an application that will send some text to the default SMS application. In order ...

Results 1 to 3 of 3

Thread: AA's Quick SMS

  1. #1
    Android Junkie allyAndroid's Avatar
    Join Date
    Jun 2010
    Location
    Ohio
    Posts
    1,413
    This is my second tutorial. It shows how you can setup an application that will send some text to the default SMS application.



    In order to use this tutorial, you must have setup your computer to develop Android Apps. Please see my previous thread: Getting Setup To Develop Android Apps.



    Prerequisites



    This tutorial does not cover setting up your computer to develop Android Apps. You must have installed JDK (Version 5 or 6), Android SDK, Eclipse (Version 3.5 or greater), and the Android Eclipse Plug-in. You must also be familiar with Java and using Eclipse.



    A New Project



    The first thing we want to do is to create a new project.



    • Open Eclipse.
    • Click on the File menu.
    • Select New -> Project.
    • In the New Project dialog box, select Android -> Android Project.
    • Click on the Next button.
    • Enter the project information:
      • Project Name: quicksms
        • The project name will be used to create the folder that Eclipse will store all of the project's files in.
      • Build Target: Android 2.1
        • The build target is the version of Android that you want to use for the application.
        • Any device that uses an earlier version of Android may not be able to run the application.
      • Application Name: AA\'s Quick SMS
        • The application name is what will appear in the application's title and is what the user will see.
      • Package Name: com.allyandroid.converter
      • Create Activity: Convert
        • The activity is the main activity that is ran when the application is opened.
      • Min SDK Version: 7
        • The min SDK is used to prevent older version of Android from being able to run the application.
        • If blank, any device can install the application even if they have an older version of Android.


    The Layout



    Next, we want to design the layout of the application. We want to add the following objects to the main layout:



    • Textbox - This is what the user will use to input data.
    • Send Quick SMS Button - The button the user touches to send the message.
    • Group of Check Boxes.
      • I am on my way.
      • Be there in a few minutes.
      • Are you ready to go?
      • What are you doing?
      • Have a good night.
      • I am in a meeting.
      • I am driving.
      • I will text you later.
      • I love you.
      • I miss you.


    In order to add these objects, we need to work with two separate files: strings.xml and main.xml.



    • Open the strings.xml file.
      • The strings.xml file is located in this folder: /res/values/.
      • Change the code in the file to the following:
          • Quick SMS
          • I am on my way.
          • Be there in a few minutes.
          • Are you ready to go?
          • What are you doing?
          • Have a good night.
          • I am in a meeting.
          • I am driving.
          • I will text you later.
          • I love you.
          • I miss you.
          • quickTextHandler
          • Send Quick SMS
          • sendMessageHandler
      • Note: We only have one handler, checkboxHandler, for all of the check boxes. Originally, we had a separate handler for each checkbox but this way is more efficient and requires less coding.
      • Save the file.
    • Open the main.xml file.
      • The main.xml file is located in this folder: /res/layout/.
      • Change the code in the file to:
      • Save the file.


    The Menu



    We want to add a menu file that contains Exit and About. A menu is what pops up when the user pushes the menu button. The menu file is not automatically created by Eclipse so we will need to create it.



    • Create the menu.xml file.
      • Create a new menu folder.
        • Right click on the res folder.
        • Select New -> Folder.
        • Enter menu for the folder name.
        • Click on the Finish button.
      • Create a new file called menu.xml.
        • Right click on the menu folder.
        • Select New -> File.
        • Enter menu.xml for the file name.
        • Click on the Finish button.
      • Open menu.xml.
        • Add the following code to the file:
      • Save the file.


    The Activity



    Now comes the fun part of programming the activities that will perform the calculations when a user enters a value, selects a radio button, and then clicks on the Calculate button. We will also create the handler activities and menu activities.



    • Open QuickSMS.java file.
      • The QuickSMS.java file is located in this folder: /src/com/allyandroid/quicksms/.
      • package com.allyandroid.quicksms;
      • // Add the following imports, if they are not already listed:
        • import android.app.Activity;
        • import android.content.Intent;
        • import android.os.Bundle;
        • import android.view.Menu;
        • import android.view.MenuInflater;
        • import android.view.MenuItem;
        • import android.view.View;
        • import android.widget.CheckBox;
        • import android.widget.EditText;
        • import android.widget.Toast;
      • // This is the main class that was created when you created the project.
        • public class QuickSMS extends Activity {
          • private EditText quickMessage;
          • private String checkBoxText;
          • @Override
          • public void onCreate(Bundle savedInstanceState) {
            • super.onCreate(savedInstanceState);
            • setContentView(R.layout.main);
            • quickMessage = (EditText) findViewById(R.id.EditText01);
          • }
        • // This activity handles the menu when the menu button is pushed.
          • public boolean onCreateOptionsMenu(Menu menu) {
            • MenuInflater inflater = getMenuInflater();
            • inflater.inflate(R.menu.menu, menu);
            • return true;
          • }
        • // This activity handles the Exit or About menu when touched.
          • @Override
          • public boolean onOptionsItemSelected(MenuItem item) {
            • switch (item.getItemId()) {
              • case R.id.exit:
                • finish();
                • return true;
              • case R.id.about:
                • Toast.makeText(this, "Ally Android's Quick SMS (www.allyandroid.com)", Toast.LENGTH_LONG).show();
            • }
            • return true;
          • }
        • // This activity handles the Send SMS button when touched.
          • public void sendMessageHandler(View view) {
            • quickMessage = (EditText) findViewById(R.id.EditText01);
            • String message = quickMessage.getText().toString();
            • if (quickMessage.length() > 0)
              • sendSMS(message);
            • else
              • Toast.makeText(getBaseContext(), "Please select at least one quick text.", Toast.LENGTH_SHORT).show();
          • }
        • // This activity handles each of the checkboxes and creates the text message.
          • public void quickTextHandler(View view) {
            • CheckBox q1 = (CheckBox) findViewById(R.id.CheckBox01);
            • CheckBox q2 = (CheckBox) findViewById(R.id.CheckBox02);
            • CheckBox q3 = (CheckBox) findViewById(R.id.CheckBox03);
            • CheckBox q4 = (CheckBox) findViewById(R.id.CheckBox04);
            • CheckBox q5 = (CheckBox) findViewById(R.id.CheckBox05);
            • CheckBox q6 = (CheckBox) findViewById(R.id.CheckBox06);
            • CheckBox q7 = (CheckBox) findViewById(R.id.CheckBox07);
            • CheckBox q8 = (CheckBox) findViewById(R.id.CheckBox08);
            • CheckBox q9 = (CheckBox) findViewById(R.id.CheckBox09);
            • CheckBox q10 = (CheckBox) findViewById(R.id.CheckBox010);
            • checkBoxText = "";
            • if (q1.isChecked()) {
              • if (checkBoxText == "") {
                • checkBoxText = (String) q1.getText();
              • } else {
                • checkBoxText = checkBoxText + " " + (String) q1.getText();
              • }
            • }
            • if (q2.isChecked()) {
              • if (checkBoxText == "") {
                • checkBoxText = (String) q2.getText();
              • } else {
                • checkBoxText = checkBoxText + " " + (String) q2.getText();
              • }
            • }
            • if (q3.isChecked()) {
              • if (checkBoxText == "") {
                • checkBoxText = (String) q3.getText();
              • } else {
                • checkBoxText = checkBoxText + " " + (String) q3.getText();
              • }
            • }
            • if (q4.isChecked()) {
              • if (checkBoxText == "") {
                • checkBoxText = (String) q4.getText();
              • } else {
                • checkBoxText = checkBoxText + " " + (String) q4.getText();
              • }
            • }
            • if (q5.isChecked()) {
              • if (checkBoxText == "") {
                • checkBoxText = (String) q5.getText();
              • } else {
                • checkBoxText = checkBoxText + " " + (String) q5.getText();
              • }
            • }
            • if (q6.isChecked()) {
              • if (checkBoxText == "") {
                • checkBoxText = (String) q6.getText();
              • } else {
                • checkBoxText = checkBoxText + " " + (String) q6.getText();
              • }
            • }
            • if (q7.isChecked()) {
              • if (checkBoxText == "") {
                • checkBoxText = (String) q7.getText();
              • } else {
                • checkBoxText = checkBoxText + " " + (String) q7.getText();
              • }
            • }
            • if (q8.isChecked()) {
              • if (checkBoxText == "") {
                • checkBoxText = (String) q8.getText();
              • } else {
                • checkBoxText = checkBoxText + " " + (String) q8.getText();
              • }
            • }
            • if (q9.isChecked()) {
              • if (checkBoxText == "") {
                • checkBoxText = (String) q9.getText();
              • } else {
                • checkBoxText = checkBoxText + " " + (String) q9.getText();
              • }
            • }
            • if (q10.isChecked()) {
              • if (checkBoxText == "") {
                • checkBoxText = (String) q10.getText();
              • } else {
                • checkBoxText = checkBoxText + " " + (String) q10.getText();
              • }
            • }
            • quickMessage.setText(checkBoxText);
          • }
        • // This activity sends the message to the default SMS application.
          • private void sendSMS(String message) {
            • Intent sendIntent = new Intent(Intent.ACTION_VIEW);
            • sendIntent.putExtra("sms_body", message);
            • sendIntent.setType("vnd.android-dir/mms-sms");
            • startActivity(sendIntent);
          • }
        • }
      • Save the file.
    Motorola Droid 4

  2. Android.net is the premier Android Forum. Registered users do not see these ads. .

  3. #2
    Android Junkie allyAndroid's Avatar
    Join Date
    Jun 2010
    Location
    Ohio
    Posts
    1,413




    QR Code for the APK file
    Motorola Droid 4

  4. #3
    Android Junkie allyAndroid's Avatar
    Join Date
    Jun 2010
    Location
    Ohio
    Posts
    1,413
    Screenshots



    Motorola Droid 4

Remove Ads

http://www.scramblerducati.org/

Sponsored Links

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search tags for this page

android eclipse if else gettext
,
android intent sms lg
,

android quick text import

,
create quicktext for sms android
,
edit quick text android folder
,
how do i set up sms on my droid ally
,
in what folder does android store sms messages?
,
lg ally edit quick text
,
quick sms android
,
quicksms android forum
,
send android sms hack
,
sendquick entera sms
,
silverlight android
,
where does android store sms messages eclipse
,
z4root apk
Click on a term to search our sites for related topics.
Android Forum