Sending a text message is a convenient way of communicating between families, friends, and colleagues. Import transmission of cellular messages is one of the major revolutions of our modern lives. Open src//MainActivity.java and paste the following. Also, we have to add the phone number and the message as extra fields to that intent. Respectively, for the intent with ACTION_VIEW we will define the type as vnd.android-dir/mms-sms, so only sms-mms providers will launch. For the intent with ACTION_SENDTO we have to define the data as smsto: and the phone number added at the end. SmsManager handles SMS operations and getDefault() method should be called, in order to get an instance of this object. Open res/layout/activity_main.xml and go to the respective xml tab. Also, we are going to add three different Buttons, that each one enables a different action and uses a suitable class ( smsManager, Intent with SENDTO action, Intent with VIEW action). We will put two EditTexts so that the user can fill in a phone number and a message for a SMS. Now, you can see the structure of your created project.Ģ. xml file for the layout will automatically be created in the res/layout folder. Specify a name for the new Activity and a name for the layout description of your app. Select the “Blank Activity” option and press Next. We will use the default icon of android, so click Next. In “Configure Launcher Icon” window you should choose the icon you want to have in your app. The new created activity will be the main activity of your project. In the next window, choose the “Create Activity” check-option. Specify the name of the application, the project and the package in the appropriate fields. Open Eclipse IDE and go to File → New → Project → Android Application Project. More specifically, we are going to send a sms by using SmsManager and implicit Intent with SENDTO action and/or VIEW action.įor this tutorial, we will use the following tools in a Windows 64-bit platform:ġ. In this example, we are going to implement both ways. In parallel, the use of Intents implies the use of built-in applications and sms clients that are installed in each Android device. The use of SmsManager facilitates the sms sending because it gives us the opportunity to customize this functionality with the manner we want, within our own Activity. There are two different ways to do such a thing: In some situations, we want to send sms messages from our own Android application.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |