|
相对于android的原生开发,利用Web的开发模式实现应用真的简答太多。目前的移动Web框架也很多,这里主要分享一下对于Rexsee的体会。
最大的价值就不多说了,大部分Web开发框架都是类似的表述,使用HTML、CSS和Javascript实现应用,而非原生基于NDK的C或者JDK的Java语言开发。
首先,不同于其它的框架,Rexsee只是针对于Android系统,而非跨平台;(好就好在支持的功能够多,效率够高;不过大部分做WebApp的第一目的就是为了跨平台。这个价值就难以比较了)
同样基于WebKit内核,通过JS注入接口;(貌似目前大部分的都是这样)
支持HTML5;(这个支持不仅仅只是针对于浏览器应用,而是指的对于系统自身功能的实现。就好像陀螺仪功能,在iOS的Safari上没问题,但Android的浏览器就无法实现,Rexsee有自己的扩展对象可以做到)
扩展Android超过1500个API;(这是很有吸引力的东西,个人判断,超过95%的系统原生功能都能直接通过JS实现调用)
APK封装功能;(无需多说)
貌似还有Flash快速移植框架、Wap站点移植框架;(我没用过,没去找)
其次是社区支持:
Rexsee是国内的自主产品,本地化支持自然没得说;
提供了全部的API介绍与源码;(可惜还未有下载,个人判断应该是想握点东西在手上吧,全部开放出来会有隐患,可以理解)
没有像样的教程和指导入门;(这是通病么?所有的Web开发框架都没有像样的教程,就是一些API和源码,看起来很费劲儿的)
技术支持;(社区论坛有专门的问答板块,有人在全天回复;有个Q群,183780108,相当热烈)
如上只是个人的观察和了解,很多可能会引发争论的暂且不议(如开源协议、收费模式、在线编译过程、入门指导、产品对比等等等)。单纯说产品,体验不错。
http://www.rexsee.com/
怕没人看,补充一段Rexsee实现的应用源码。这是在Rexsee最新推出的项目中心里看到的。
哦,多说一句,这是Rexsee最新推出的在线开发频道,不需要服务器空间,在线开发,一些图片和页面源码之类的,直接传到Rexsee的服务器上去就行了。补一张截图,一些常规的Android原生功能直接勾选权限就OK。<img src="attachments/dvbbs/2011-12/2011122019172933248.jpg" border="0" onclick="zoom(this)" onload="if(this.width>document.body.clientWidth*0.5) {this.resized=true;this.width=document.body.clientWidth*0.5;this.style.cursor='pointer';} else {this.onclick=null}" alt="" />
同时,该频道最大的价值在于应用的共享。但凡新创建的项目默认状态均为分享状态,也就是说应用中的全部源码对外开放。如下便是一个基于Rexsee实现的,在Android系统上的方向感应的小应用。可以根据手机的摆放位置发出反馈。哈哈,具体的不剧透,大家可以去Rexsee的项目中心自己下载
整个应用只有一个HTML的首页(而且还是黑屏),就是在body里面套了JS代码,源码如下
window.onRexseeReady = function(){
rexseeScreen.setScreenAlwaysOn(true);
rexseeScreen.setScreenOrientation("portrait");
rexseeMenu.create("mainOptionsMenu","label:mainOptionsMenu");
rexseeMenu.addItem("mainOptionsMenu","rexsee:reload","label:刷新;");
rexseeMenu.addItem("mainOptionsMenu","javascript:quit();","label:退出;");
rexseeMenu.setOptionsMenuId("mainOptionsMenu");
rexseeSpecialKey.enableBackKeyListener(true);
rexseeSpecialKey.setBackKeyListener('javascript:quit();');
if ( window.confirm("本应用可能给别人带来不适,在他/她的愤怒和惊骇下,可能损坏您的手机,极端情况下可能给您带来人身危险,您确定要启动该应用吗?")){
alert("请把手机放到桌面上,然后按确定。");
rexseeScreen.setFullScreen(true);
rexseeTitleBar.setStyle("visibility:hidden;");
rexseeStatusBar.setStyle("visibility:hidden;");
rexseeOrientation.stop();
start = false;
rexseeOrientation.start();
} else {
rexseeApplication.quit();
}
}
function quit(){
if ( window.confirm("退出该程序是明智的选择,以免影响您和他人的和谐关系,确实要退出吗?") ){
rexseeOrientation.stop();
rexseeAudioPlayer.stop();
rexseeApplication.quit();
}
}
var lang_start = "file:///android_asset/start.mp3";
var lang_finish = "file:///android_asset/finish.mp3";
var lang_yz_1 = "file:///android_asset/yz_1.mp3";
var lang_yz_2 = "file:///android_asset/yz_2.mp3";
var lang_yz_3 = "file:///android_asset/yz_3.mp3";
var lang_yz_4 = "file:///android_asset/yz_4.mp3";
var lang_yz_good = "file:///android_asset/yz_good.mp3";
var lang_left_1 = "file:///android_asset/left_1.mp3";
var lang_left_2 = "file:///android_asset/left_2.mp3";
var lang_left_3 = "file:///android_asset/left_3.mp3";
var lang_left_4 = "file:///android_asset/left_4.mp3";
var lang_left_good = "file:///android_asset/left_good.mp3";
var lang_right_1 = "file:///android_asset/right_1.mp3";
var lang_right_2 = "file:///android_asset/right_2.mp3";
var lang_right_3 = "file:///android_asset/right_3.mp3";
var lang_right_4 = "file:///android_asset/right_4.mp3";
var lang_right_good = "file:///android_asset/right_good.mp3";
var nextLang = "";
var talking = false;
function talk(lang){
switch(lang){
case "start": nextLang = lang_start; break;
case "finish": nextLang = lang_finish; break;
case "yz_1": nextLang = lang_yz_1; break;
case "yz_2": nextLang = lang_yz_2; break;
case "yz_3": nextLang = lang_yz_3; break;
case "yz_4": nextLang = lang_yz_4; break;
case "yz_good": nextLang = lang_yz_good; break;
case "left_1": nextLang = lang_left_1; break;
case "left_2": nextLang = lang_left_2; break;
case "left_3": nextLang = lang_left_3; break;
case "left_4": nextLang = lang_left_4; break;
case "left_good": nextLang = lang_left_good; break;
case "right_1": nextLang = lang_right_1; break;
case "right_2": nextLang = lang_right_2; break;
case "right_3": nextLang = lang_right_3; break;
case "right_4": nextLang = lang_right_4; break;
case "right_good": nextLang = lang_right_good; break;
default: return;
}
if ( !talking ) {
rexseeAudioPlayer.start(nextLang,false);
rexseeAudioPlayer.setVolume(1);
talking=true;
//window.setTimeout("talking=false;",2000);
}
}
var accuracy = 10;
var start = false;
var startTalk = false;
var sleepingX = 0;
var lastOffsetX = 0;
var lastOffsetYZ = 0;
var wrongTimeLeft = 0;
var wrongTimeRight = 0;
var wrongTimeYZ = 0;
function onOrientationChanged(){
var x = rexseeOrientation.getLastKnownX();
var y = rexseeOrientation.getLastKnownY();
var z = rexseeOrientation.getLastKnownZ();
if ( !start ){
sleepingX=Math.round(x);
start = true;
return;
} else {
var offsetX = Math.round(x-sleepingX);
var absX = Math.abs(offsetX);
var absYZ = Math.max(Math.abs(y),Math.abs(z));
if ( absYZ > accuracy ){ //不平
if ( !startTalk ){
talk("start");
startTalk = true;
return;
}
if ( wrongTimeYZ==0 ){
talk("yz_1");
wrongTimeYZ = 1;
} else {
if ( absYZ >= lastOffsetYZ ){
switch ( wrongTimeYZ ){
case 1: talk("yz_2"); break;
case 2: talk("yz_3"); break;
case 3: talk("yz_4"); break;
}
wrongTimeYZ++;
if ( wrongTimeYZ>3 ) wrongTimeYZ = 0;
} else {
talk("yz_good");
wrongTimeYZ--;
}
}
lastOffsetYZ = absYZ;
} else if ( offsetX > accuracy) { //太右
if ( !startTalk ){
talk("start");
startTalk = true;
return;
}
if ( wrongTimeRight==0 ){
talk("right_1");
wrongTimeRight = 1;
} else {
if ( offsetX >= lastOffsetX ){
switch ( wrongTimeRight ){
case 1: talk("right_2"); break;
case 2: talk("right_3"); break;
case 3: talk("right_4"); break;
}
wrongTimeRight++;
if ( wrongTimeRight>3 ) wrongTimeRight = 0;
} else {
talk("right_good");
wrongTimeRight--;
}
}
lastOffsetX = offsetX;
} else if ( offsetX < -accuracy) { //太左
if ( !startTalk ){
talk("start");
startTalk = true;
return;
}
if ( wrongTimeLeft==0 ){
talk("left_1");
wrongTimeLeft = 1;
} else {
if ( offsetX <= lastOffsetX ){
switch ( wrongTimeLeft ){
case 1: talk("left_2"); break;
case 2: talk("left_3"); break;
case 3: talk("left_4"); break;
}
wrongTimeLeft++;
if ( wrongTimeLeft>3 ) wrongTimeLeft = 0;
} else {
talk("left_good");
wrongTimeLeft--;
}
}
lastOffsetX = offsetX;
} else {
if (startTalk && !talking){
startTalk = false;
lastOffsetX = 0;
lastOffsetYZ = 0;
wrongTimeLeft = 0;
wrongTimeRight = 0;
wrongTimeYZ = 0;
talk("finish");
}
}
}
}
window.onException = function(className, message){
rexseeDialog.alert("系统错误","Class: "+className+"
Error: "+unescape(message));
}
window.onAudioPlayCompleted = function(){
talking=false;
} |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
×
|