- 浏览: 20111 次
- 性别:
- 来自: 北京
最新评论
-
sylar029:
谢谢,楼主回答!
如何基于Rexsee实现以Web开发方式创建Android应用 -
rexsee:
sylar029 写道你好!问你个问题,如果是c/s结构的? ...
如何基于Rexsee实现以Web开发方式创建Android应用 -
sylar029:
你好!问你个问题,如果是c/s结构的? 你的后台服务器用什么? ...
如何基于Rexsee实现以Web开发方式创建Android应用
基于rexsee扩展的rexseeSMS,通过JS实现短信读取相关功能,如:
【函数】 JsonArray getContentUris()
【说明】 读取短信相关的所有数据库表的Uri地址。
【返回】 Json对象字符串,可以用eval('('+json+')')转换为JavaScript对象。
【参数】 无
【示例】
Html代码
- alert(rexseeSMS.getContentUris());
【函数】 JsonObjectArray get(int number)
【说明】 读取若干条短信。
【返回】 Json对象数组字符串,可以用eval('('+json+')')转换为JavaScript对象数组,注意,其中body字段是escape过的,使用前需要unescape。
【参数】 number:要读取的短信条数。
【示例】
Html代码
- alert(rexseeSMS.get(10));
- alert(unescape(eval('('+rexseeSMS.get(1)+')')[0].body));
其它还有:
- getUnread(int number):读取若干条未读短信;
- getRead(int number):读取若干条已读短信;
- getInbox(int number):从收件箱读取若干条短信;
- getSent(int number):读取若干条已发短信;
- getByThread(int threadID):读取会话中所有短信;
- getThreads(int number):读取若干条会话;
- getData(String selection, int number):根据条件读取若干条短信。
详细源码:
/* * Copyright (C) 2011 The Rexsee Open Source Project * * Licensed under the Rexsee License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.rexsee.com/CN/legal/license.html * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package rexsee.communication; import rexsee.core.browser.JavascriptInterface; import rexsee.core.browser.RexseeBrowser; import rexsee.core.utilities.Escape; import android.content.ContentResolver; import android.content.Context; import android.database.Cursor; import android.net.Uri; public class RexseeSMS implements JavascriptInterface { private static final String INTERFACE_NAME = "SMS"; @Override public String getInterfaceName() { return mBrowser.application.resources.prefix + INTERFACE_NAME; } @Override public JavascriptInterface getInheritInterface(RexseeBrowser childBrowser) { return this; } @Override public JavascriptInterface getNewInterface(RexseeBrowser childBrowser) { return new RexseeSMS(childBrowser); } public static final String CONTENT_URI_SMS = "content://sms"; public static final String CONTENT_URI_SMS_INBOX = "content://sms/inbox"; public static final String CONTENT_URI_SMS_SENT = "content://sms/sent"; public static final String CONTENT_URI_SMS_CONVERSATIONS = "content://sms/conversations"; public static String[] SMS_COLUMNS = new String[]{ "_id", //0 "thread_id", //1 "address", //2 "person", //3 "date", //4 "body", //5 "read", //6; 0:not read 1:read; default is 0 "type", //7; 0:all 1:inBox 2:sent 3:draft 4:outBox 5:failed 6:queued "service_center" //8 }; public static String[] THREAD_COLUMNS = new String[]{ "thread_id", "msg_count", "snippet", }; private final Context mContext; private final RexseeBrowser mBrowser; public RexseeSMS(RexseeBrowser browser) { mBrowser = browser; mContext = browser.getContext(); } //JavaScript Interface public String getContentUris() { String rtn = "{"; rtn += "\"sms\":\"" + CONTENT_URI_SMS + "\""; rtn += ",\"inbox\":\"" + CONTENT_URI_SMS_INBOX + "\""; rtn += ",\"sent\":\"" + CONTENT_URI_SMS_SENT + "\""; rtn += ",\"conversations\":\"" + CONTENT_URI_SMS_CONVERSATIONS + "\""; rtn += "}"; return rtn; } public String get(int number) { return getData(null, number); } public String getUnread(int number) { return getData("type=1 AND read=0", number); } public String getRead(int number) { return getData("type=1 AND read=1", number); } public String getInbox(int number) { return getData("type=1", number); } public String getSent(int number) { return getData("type=2", number); } public String getByThread(int thread) { return getData("thread_id=" + thread, 0); } public String getData(String selection, int number) { Cursor cursor = null; ContentResolver contentResolver = mContext.getContentResolver(); try { if (number > 0) { cursor = contentResolver.query(Uri.parse(CONTENT_URI_SMS), SMS_COLUMNS, selection, null, "date desc limit " + number); } else { cursor = contentResolver.query(Uri.parse(CONTENT_URI_SMS), SMS_COLUMNS, selection, null, "date desc"); } if (cursor == null || cursor.getCount() == 0) return "[]"; String rtn = ""; for (int i = 0; i < cursor.getCount(); i++) { cursor.moveToPosition(i); if (i > 0) rtn += ","; rtn += "{"; rtn += "\"_id\":" + cursor.getString(0); rtn += ",\"thread_id\":" + cursor.getString(1); rtn += ",\"address\":\"" + cursor.getString(2) + "\""; rtn += ",\"person\":\"" + ((cursor.getString(3) == null) ? "" : cursor.getString(3)) + "\""; rtn += ",\"date\":" + cursor.getString(4); rtn += ",\"body\":\"" + Escape.escape(cursor.getString(5)) + "\""; rtn += ",\"read\":" + ((cursor.getInt(6) == 1) ? "true" : "false"); rtn += ",\"type\":" + cursor.getString(7); rtn += ",\"service_center\":" + cursor.getString(8); rtn += "}"; } return "[" + rtn + "]"; } catch (Exception e) { mBrowser.exception(getInterfaceName(), e); return "[]"; } } public String getThreads(int number) { Cursor cursor = null; ContentResolver contentResolver = mContext.getContentResolver(); try { if (number > 0) { cursor = contentResolver.query(Uri.parse(CONTENT_URI_SMS_CONVERSATIONS), THREAD_COLUMNS, null, null, "thread_id desc limit " + number); } else { cursor = contentResolver.query(Uri.parse(CONTENT_URI_SMS_CONVERSATIONS), THREAD_COLUMNS, null, null, "thread_id desc"); } if (cursor == null || cursor.getCount() == 0) return "[]"; String rtn = ""; for (int i = 0; i < cursor.getCount(); i++) { cursor.moveToPosition(i); if (i > 0) rtn += ","; rtn += "{"; rtn += "\"thread_id\":" + cursor.getString(0); rtn += ",\"msg_count\":" + cursor.getString(1); rtn += ",\"snippet\":\"" + Escape.escape(cursor.getString(2)) + "\""; rtn += "}"; } return "[" + rtn + "]"; } catch (Exception e) { mBrowser.exception(getInterfaceName(), e); return "[]"; } } }
发表评论
-
Rexsee API介绍:Android定时任务Alarm,附基本的闹钟功能示例
2012-06-19 11:36 1599利用Rexsee扩展的Alarm可以快速实现关于任务定时 ... -
Rexsee API介绍:Android屏幕锁定Keyguard
2012-06-19 11:36 1509Android锁屏时会先调用onPause();解锁时调 ... -
Rexsee API介绍:Android WakeLock进程持续
2012-06-14 10:15 1144在Android中,WakeLock可以让进程持续执行, ... -
Rexsee API介绍:CallLog通话记录
2012-06-14 10:14 1300rexseeCallLog对象,实现自定义数量的最近通话 ... -
Rexsee API介绍:SMSSender短信发送
2012-06-14 10:13 1022rexseeSMSSender扩展,实现短信发送与事件回 ... -
Rexsee API:Android照片、视频拍摄,Camera扩展
2012-03-26 09:48 87Android的Camera包含取景(preview)和 ... -
Rexsee API介绍:Android视频播放,Rexsee的VideoPlayer函数说明与源码
2012-03-21 11:59 37在Android上实现视频播放并不是非常困难,可以直接通 ... -
Rexsee API介绍:Android音频录制,AudioRecorder函数与源码
2012-03-20 18:25 120Audio系统在Android中负责音频方面输入/输出层 ... -
Rexsee API介绍:基站定位功能,Android CellLocation源码
2012-03-20 10:28 84先提示一点,不能使 ... -
Rexsee API介绍:Android定时任务Alarm,附基本的闹钟功能示例
2012-03-19 09:26 98利用Rexsee扩展的Alarm ... -
Rexsee API介绍:Android屏幕锁定,Keyguard函数与扩展源码
2012-03-16 09:56 80Android锁屏时会先调用onPause();解锁时调 ... -
Rexsee API介绍:Android WakeLock进程持续,阻止应用休眠
2012-03-15 17:54 69在Android中,WakeLock可以让进程持续执行, ... -
Rexsee API介绍:CallLog通话记录
2012-03-14 17:59 67rexseeCallLog对象,实现自定义数量的最近通话 ... -
Rexsee API介绍:SMSSender短信发送
2012-03-12 12:36 95rexseeSMSSender扩展,实现短信发送与事件回 ... -
Rexsee API介绍:SMS短信读取
2012-03-12 10:39 70Rexsee是一个开源的移动Web开发平台,深度支持 ...
相关推荐
Rexsee是什么 Rexsee是基于Android的HTML5开发平台,帮助开发者使用HTML5+JavaScript开发Android应用。 Rexsee的特点 编程语言使用 HTML5+CSS3+JavaScript+Rexsee扩展API。 超过2000个JavaScript扩展API,功能强大。...
编程语言使用 HTML5+CSS3+JavaScript+Rexsee扩展API。 超过2000个JavaScript扩展API,功能强大。 支持第三方JavaScript开发框架。 B/C/S混合架构,支持应用程序本地化,摆脱网络依赖。 全面支持Android原生UI布局,...
了解使用Rexsee EMS开发Android手机应用的好资料
rexsee手机本地版开发手册
编程语言使用 HTML5+CSS3+JavaScript+Rexsee扩展API。 超过2000个JavaScript扩展API,功能强大。 支持第三方JavaScript开发框架。 B/C/S混合架构,支持应用程序本地化,摆脱网络依赖。 全面支持Android原生UI布局,...
Rexsee是基于Android的HTML5开发平台,帮助开发者使用HTML5+JavaScript开发Android应用。
Rexsee是基于Android的HTML5开发平台,帮助开发者使用HTML5+JavaScript开发Android应用
Rexsee源代码,Rexsee系统的源代码。从他的网站上一点一点搞下来的。哈哈。。你懂的。
NULL 博文链接:https://key232323.iteye.com/blog/1779445
rexsee目前取消了在线生成功能,只提供了简单的安装指引,但这个指引对于安卓菜鸟来说过于简单,而且其中有几处重大缺漏。本人对官方文档进行了补充说明,并介绍了自己遇到的经验教训,希望对擅长webapp开发,而又不...
Android移动中间件Rexsee开发手册,利用它可以快速开发Android应用程序,只需要你掌握HTML+CSS+JavaScript,而需要掌握java和Android SDK。让你快速得进入到移动开发的大门。
Web应用,Rexsee,开源,Web开发,JS,Android,Web技术,应用趋势,应用范围,移动终端,,开源Rexsee模糊原生应用与W,开源Rexsee模糊原生应用与Web应用界线
目前大家所知道的基于中间件的移动开发框架都是采用的 Hybrid 开发模式,例如国外的 PhoneGap、Titanium、Sencha,还有国内的 AppCan、Rexsee 等等。Hybrid App 开发模式正在被越来越多的公司和开发者所认同,相信...
摘要:PHP源码,管理系统,ESM,销售管理系统 ESM企业... 中间件层包括函数库rexsee,由java开发,android操作系统、中间件、用户界面和应用软件组成。 服务器端新增功能模块: 1.客户拜访 2.公告文档 3.产品管理 4