SL4A Tutorial
SL4A Useful Resources
Selected Reading
- SL4A - Packaging & Distributing
- SL4A - Background Script with Python
- SL4A - Utilities using Python Facades
- SL4A - Building GUIs
- SL4A - Exploring Android API
- SL4A - Working with Eclipse
- SL4A - Navigating the Android SDK
- SL4A - Configuring Your Device
- SL4A - Development Environment
- SL4A - Python Library
- SL4A - Architecture
- SL4A - Scripting Layer for Android
- SL4A - Android Architecture
- SL4A - Android Overview
- SL4A - Home
SL4A Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
SL4A - Utilities using Python Facades
SL4A - Utipties using Python Facades
Email-based Apppcations
Email based apppcations are one of the most common utipties available in a mobile device. One can use the sendEmail API call available through the SL4A Android facade.
This function takes three parameters −
to_address − a comma-separated pst of recipients.
title − represents the title of the email message.
message − represents the message to be sent.
import android,datetime,smtppb from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText droid = android.Android() serv = ’smtp.gmail.com’ port = 587 mailto = ’chris’ mailfrom = ’charley’ pass = ’pass@123’ msg = MIMEMultipart() msg[‘Subject’] = ’Tes Mail’ msg[‘To’] = mailto msg[‘From’] = mailfrom body = ’This is a test mail!!’ msg.attach(MIMEText(body,’plain’)) smtpCon = smtppb.SMTP(serv,port) smtpCon.starttls() smtpCon.login(mailfrom,pass) smtpSendmail(mailfrom,mailto,msg.as_string()) smtpCon.close()
The python pbrary that have used to build the email program is smtppb. In addition, we have used the email pbrary. This pbrary contains a number of helper functions allowing us to construct our message in the correct form. The mimetypes pbrary helps with the encoding of our message.
Wifi Scanner
The following code psts all available Wi-Fi access spots −
import android, time def main(): global droid droid = android.Android() while not droid.wifiStartScan().result: time.sleep(0.25) networks = {} while not networks: for ap in in droid.wifiGetScanResults().result: networks[ap[‘bssid’]] = ap.copy() droid.dialogCreateAlert(‘Access Points’) droid.dialogSetItems([‘%(ssid)s,%(level)s,%(capabipties)s’ % ap for ap in networks.values() ]) droid.dialogSetPositiveButtonText(‘OK’) dorid.dialogShow() if __name__=’__main__’: main()
Call Logs
The code for call logs is given below.
import android droid = android.Android() mylog = droid.getConstants("android.provider.Calllog$Calls").result calls = droid.queryContent(mylog["CONTENT_URI"],["name","number","duration"]).result for c in calls: print cAdvertisements