Sl4A_ApiReference examples(1)

来源:互联网 发布:mac用excel怎么截图 编辑:程序博客网 时间:2024/06/03 22:14

环境:sl4a_r4.apk, PythonForAndroid_r4.apk,打开Android emulator 2.2

1. makeToast  显示短暂提示框
  makeToast(
  String message)
 显示一个持续短暂时间的提示框。

import android
droid=android.Android()
droid.makeToast('Hello World!')

2.notify 通知
notify(
String title: 标题,
String message)
在状态栏会显示一个通知,在用户点击后会取消。

import android
droid=android.Android()
droid.notify('Message','I will go home!')

3.viewContacts 打开联系人列表
viewContacts() 打开联系人列表。
import android
droid=android.Android()
droid.viewContacts()

4.phoneCallNumber
拨打一个电话号码
phoneCallNumber(
String phone number)
拨打一个电话号码。
import android
droid=android.Android()
droid.phoneCallNumber('13569874596')
脚本运行后会拨打一个电话

5.getPassword
请求用户输入密码
getPassword(
String title[optional, default SL4A Password Input]: title of the input box,
String message[optional, default Please enter password:]: message to display
above the input box)
请求用户输入密码。
已废弃!请使用dialogGetPassword方法替代。
import android
droid=android.Android()
droid.getPassword()
droid.dialogGetPassword()

6. search
搜索给定的查询字符串
search(
String query)
搜索给定的查询字符串。
import android

droid=android.Android()

droid.search('android')

打开浏览器搜索'android'相关内容

原创粉丝点击