SMS Read received SMS Read sent SMS Send SMS New app, SMSFun Button – Text: Send SMS – Id: sendSMSButton Permissions – send_sms – read_sms – receive_sms.

Slides:



Advertisements
Similar presentations
Android Application Development Tutorial. Topics Lecture 6 Overview Programming Tutorial 3: Sending/Receiving SMS Messages.
Advertisements

1 Android Introduction Hello Threads. 2 Goal Create an application that uses a background thread as a UDP server to receive messages from the UDP client.
WiFi in Android.
Monitoring battery use. New app, BatteryMonitor Add permission: BATTERY_STATS The battery is monitored by receiving broadcasts of battery state information.
ListView Examples. Basic Steps for Creating a Listview 1.Create a layout (e.g., a LinearLayout), with elements for –the ListView (
MESSAGING. Overview  SMS sends short text messages between mobile phones.  Supports sending both text messages and data messages  MMS (multimedia messaging.
Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at
1 Working with Webservices Nilanjan Banerjee Mobile Systems Programming University of Arkansas Fayetteville, AR
1 Working with the Android Services Nilanjan Banerjee Mobile Systems Programming University of Arkansas Fayetteville, AR
Cosc 5/4730 Android SMS. A note first Depending on the API level, an import changes because of a deprecated API 3 uses – import android.telephony.gsm.SmsManager;
System broadcasts and services. System broadcast events. EventDescription Intent.ACTION_BOOT_COMPLETEDBoot completed. Requires the android.permission.RECE.
Cosc 5/4730 Android SMS and MMS.
SMS. Short Message Service – Primarily text messages between mobile phones – First one sent December 3, 1982 “Merry Christmas” – In 2008 Approximately.
Cosc 4730 Android TabActivity and ListView. TabActivity A TabActivity allows for multiple “tabs”. – Each Tab is it’s own activity and the “root” activity.
Multimedia.
Cosc 5/4730 A little on threads and Messages: Handler class.
Monitoring battery power. overview Battery usage is critical on mobile apps Measuring energy usage is a bit tricky since many processes Android provides.
1 CSCE 4013: Mobile Systems Programming Nilanjan Banerjee Mobile Systems Programming (Acknowledgment to Deepa Shinde and Cindy Atheron University of Arkansas.
Developing Push Notifications (C2DM) for Android Vijai Co-Founder Adhish Technologies, Sweet’N’Spicy apps.
Mobile Computing Lecture#08 IntentFilters & BroadcastReceivers.
Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at
Google Cloud Messaging for Android (GCM) is a free service that helps developers send data from servers to their Android.
Broadcast intents.
8. Notification과 Alarm.
Integrating with Android Services. Introduction  Android has numerous built-in functionality that can be called from within your applications  SMS/MMS.
Cosc 5/4730 Broadcast Receiver. Broadcast receiver A broadcast receiver (short receiver) – is an Android component which allows you to register for system.
Android ICC Part II Inter-component communication.
Mobile Programming Lecture 6
DUE Hello World on the Android Platform.
16 Services and Broadcast Receivers CSNB544 Mobile Application Development Thanks to Utexas Austin.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
Android Programming-Activity Lecture 4. Activity Inside java folder Public class MainActivity extends ActionBarActivity(Ctrl + Click will give you the.
Android Boot Camp for Developers Using Java, 3E
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 2: Simplify! The Android User Interface.
Tracking Tasks and Processes. GET_TASK Make a new app, WatchProcesses – Add permission GET_TASK This permission allows the app to collect lots of information.
Cosc 5/4730 Android Communications Intents, callbacks, and setters.
Project report Android Mobile Programing. Hung Pham Danh Huynh Thuong Le An Le.
@2010 Mihail L. Sichitiu1 Android Introduction Hello Threads.
Mobile Programming Midterm Review
Android System Security Xinming Ou. Android System Basics An open-source operating system for mobile devices (AOSP, led by Google) – Consists of a base.
New Activity On Button Click via Intent. App->res->Layout->Blank Activity A new xml file is created and a new class is added to java folder. In manifest.xml.
Services Background operating component without a visual interface Running in the background indefinitely Differently from Activity, Service in Android.
Lecture 2: Android Concepts
Cosc 4735 Activities, fragments, callbacks/listeners/interfaces.
Contents Searches related to Android RatingBar Basics Android ratingbar example Android custom ratingbar.
Field Trip #30 A Memory Game By Keith Lynn. View A View is the basic building block of an app Some Views hold other views An example of this is GridLayout.
Speech Service & client(Activity) 오지영.
Mobile Programming Lecture 4 Resources, Selection, Activities, Intents.
Intents and Broadcast Receivers Dr. David Janzen Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution.
Mobile Software Development for Android - I397 IT COLLEGE, ANDRES KÄVER, WEB:
David Sutton SMS TELEPHONY IN ANDROID. OUTLINE  This week’s exercise, an SMS Pub Quiz  Simulating telephony on an emulator  Broadcast Intents and broadcast.
By: Eliav Menachi.  On Android, all application data (including files) are private to that application  Android provides a standard way for an application.
Messaging and Networking. Objectives Send SMS messages using the Messaging app Send SMS messages programmatically from within your app Receive and consume.
Mobile Software Development for Android - I397
Lecture 2: Android Concepts
CS499 – Mobile Application Development
Broadcast receivers.
Android System Security
Android – Event Handling
Messaging Unit-4.
Reactive Android Development
Mobile Software Development for Android - I397
Developing Android Services
CIS 470 Mobile App Development
Android Notifications (Part 2) Plus Alarms and BroadcastReceivers
CIS 470 Mobile App Development
Android Developer Fundamentals V2 Lesson 5
Notifying from the Background
Mobile Programming Broadcast Receivers.
CA16R405 - Mobile Application Development (Theory)
Presentation transcript:

SMS Read received SMS Read sent SMS Send SMS New app, SMSFun Button – Text: Send SMS – Id: sendSMSButton Permissions – send_sms – read_sms – receive_sms – // not broadcast_sms. This is for when the system announces a SMS has been received. But only the system is allowed to make use of this permission. There are a few permissions like this.

Reading a received SMS overview – Make SMSReceiver class that extends BroadcastReceiver – Use manifest to tell system to send received SMS to this class New class – SMSReceiver extends BroadcastReceiver – In on Receive, add Bundle bundle = intent.getExtras(); SmsMessage[] msgs = null; if (bundle != null) { – Object[] pdus = (Object[]) bundle.get("pdus"); – msgs = new SmsMessage[pdus.length]; – for (int i=0; i<msgs.length; i++) { » msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]); » String str = ""; » str += "SMS from " + msgs[i].getOriginatingAddress() + " "; » str += "SMS Body "+ msgs[i].getMessageBody().toString() + " "; » //---display the new SMS message--- » Toast.makeText(context, str, Toast.LENGTH_SHORT).show(); » Log.e("SMS Receiver","Received Message: "+str); – } } In manifest – Application tab Application nodes – Add » Receiver On right, in name, browse and find the class you just made In application nodes – Click on the SMSReciever that was just added – Add » IntentFilter In application nodes – Click on IntentFilter just added – Add » Action On right, select android.provider.Telephony.SMS_RECEIVED Run: send a sms to this phone and see if it shows up

Recording sent SMS New class SMSRecorder Member variables – Context context; – Handler handler; – ContentResolver contentResolver; – public MyObserver myObserver; Constructor – SMSRecorder(Context _context) { this.context = _context; handler = new Handler(); – } public void startRecording() { – myObserver = new MyObserver(handler); – contentResolver = context.getContentResolver(); – contentResolver.registerContentObserver(Uri.parse("content://sms"),true, myObserver); } public void stopRecording() { – contentResolver.unregisterContentObserver(myObserver); }

ContentObserver class MyObserver extends ContentObserver { – public MyObserver(Handler handler) { super(handler); – } – public void onChange(boolean selfChange) { super.onChange(selfChange); Uri uriSMSURI = Uri.parse("content://sms"); Cursor cur = context.getContentResolver().query(uriSMSURI, null, null, null, null); // this will make it point to the first record, which is the last SMS sent cur.moveToNext(); String content = cur.getString(cur.getColumnIndex("body")); String address = "nothing"; //cur.getString(cur.getColumnIndex("address")); Log.e("sms recorder","sms sent to: "+address+" with body: "+content); // show each column... each piece of data that could be recorded for (int i=0; i<cur.getColumnCount(); i++) – Log.e("sms recorder: column",cur.getColumnName(i)); cur.close(); // or call cur.moveToNext(); to process an older sms – } }

In Activity Member variable – SMSRecorder smsRecorder; In onCreate – smsRecorder = new SMSRecorder(this); – smsRecorder.startRecording(); New function – public void onDestroy() { super.onDestroy(); smsRecorder.stopRecording(); – } Run: send a sms somewhere

Send SMS In onCreate – Button sendSMSButton = (Button)findViewById(R.id.sendSMSButton); – sendSMSButton.setOnClickListener(new View.OnClickListener() public void onClick(View v) { – PendingIntent pi = PendingIntent.getActivity(SMSFunActivity.this, 0, – new Intent(SMSFunActivity.this, SMSFunActivity.class), 0); – SmsManager sms = SmsManager.getDefault(); – sms.sendTextMessage(" ", null, "test", pi, null); // first null is the SMS center which will receive and route the SMS. The second null could be an intent that will be generated when the sms is sent – //sms.sendMultipartTextMessage – //sms.sendDataMessage } – }); Run. Try you own number (i.e., send sms to yourself)