資源簡介
Google官方博客介紹了Android Scripting Environment(ASE、SL4A),將腳本語言帶入Android,允許用戶編輯和執行腳本,直接在Android設備上運行交互式解釋器。腳本將能大幅度簡化任務界面,用戶能在交互式終端中使用腳本。ASE目前支持Python,Lua和 BeanShell,未來將加入對Ruby和JavaScript的支持。示例代碼require?"android"android.startSensing()android.sleep(1)??--Give?the?sensors?a?moment?to?come?online.silent?=?falsewhile?true?do??s?=?android.readSensors()??facedown?=?s.result?and?s.result.zforce?and?s.result.zforce?>?9??if?facedown?and?not?silent?then????android.vibrate()??--A?short?vibration?to?indicate?we?are?in?silent?mode.????android.setRingerSilent(true)????silent?=?true??elseif?not?facedown?and?silent?then????android.setRingerSilent(false)????silent?=?false??end??android.sleep(1)end
標簽:SL4A
標簽:SL4A
代碼片段和文件信息
/*
?*?Copyright?(C)?2009?Google?Inc.
?*
?*?Licensed?under?the?Apache?License?Version?2.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.apache.org/licenses/LICENSE-2.0
?*
?*?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?com.googlecode.bshforandroid;
import?android.content.Context;
import?android.content.SharedPreferences;
import?android.preference.PreferenceManager;
import?com.googlecode.android_scripting.Log;
import?com.googlecode.android_scripting.interpreter.InterpreterConstants;
import?com.googlecode.android_scripting.interpreter.Sl4aHostedInterpreter;
import?java.io.File;
import?java.util.ArrayList;
import?java.util.Arrays;
import?java.util.HashMap;
import?java.util.List;
import?java.util.Map;
public?class?BshDescriptor?extends?Sl4aHostedInterpreter?{
??private?final?static?String?BSH_JAR?=?“bsh-2.0b4-dx.jar“;
??private?static?final?String?ENV_DATA?=?“ANDROID_DATA“;
??public?String?getExtension()?{
????return?“.bsh“;
??}
??public?String?getName()?{
????return?“bsh“;
??}
??public?String?getNiceName()?{
????return?“BeanShell?2.0b4“;
??}
??public?boolean?hasInterpreterArchive()?{
????return?false;
??}
??public?boolean?hasExtrasArchive()?{
????return?true;
??}
??public?boolean?hasscriptsArchive()?{
????return?true;
??}
??public?int?getVersion()?{
????return?3;
??}
??@Override
??public?File?getBinary(Context?context)?{
????return?new?File(DALVIKVM);
??}
??@Override
??public?List?getArguments(Context?context)?{
????String?absolutePathToJar?=?new?File(getExtrasPath(context)?BSH_JAR).getAbsolutePath();
????List?result?=
????????new?ArrayList(Arrays.asList(“-classpath“?absolutePathToJar
????????????“com.android.internal.util.Withframework“?“bsh.Interpreter“));
????try?{
??????SharedPreferences?preferences?=?PreferenceManager.getDefaultSharedPreferences(context);
??????if?(preferences?!=?null)?{
????????int?heapsize?=?Integer.parseInt(preferences.getString(“heapsize“?“0“)?10);
????????if?(heapsize?>?0)?{
??????????result.add(0?“-Xmx“?+?heapsize?+?“m“);
????????}
??????}
????}?catch?(Exception?e)?{
??????Log.e(e);
????}
????return?result;
??}
??@Override
??public?Map?getEnvironmentVariables(Context?unused)?{
????Map?values?=?new?HashMap();
????values.put(ENV_DATA?InterpreterConstants.SDCARD_ROOT?+?getClass().getPackage().getName());
????return?values;
??}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-06-14?06:58??sl4a-master\
?????文件?????????486??2015-06-14?06:58??sl4a-master\.hgignore
?????文件???????11358??2015-06-14?06:58??sl4a-master\LICENSE
?????文件????????1698??2015-06-14?06:58??sl4a-master\README.md
?????目錄???????????0??2015-06-14?06:58??sl4a-master\android\
?????目錄???????????0??2015-06-14?06:58??sl4a-master\android\.settings\
?????文件???????21916??2015-06-14?06:58??sl4a-master\android\.settings\org.eclipse.jdt.core.prefs
?????文件?????????114??2015-06-14?06:58??sl4a-master\android\.settings\org.eclipse.jdt.ui.prefs
?????目錄???????????0??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\
?????文件?????????540??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\.classpath
?????文件?????????822??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\.project
?????目錄???????????0??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\.settings\
?????文件???????21916??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\.settings\org.eclipse.jdt.core.prefs
?????文件????????5193??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\.settings\org.eclipse.jdt.ui.prefs
?????文件????????1305??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\AndroidManifest.xm
?????文件?????????445??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\project.properties
?????目錄???????????0??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\res\
?????目錄???????????0??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\res\drawable\
?????文件????????2233??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\res\drawable\bsh_icon.png
?????目錄???????????0??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\res\layout\
?????文件?????????393??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\res\layout\main.xm
?????目錄???????????0??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\res\values\
?????文件?????????123??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\res\values\strings.xm
?????目錄???????????0??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\res\xm
?????文件?????????383??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\res\xm
?????目錄???????????0??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\src\
?????目錄???????????0??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\src\com\
?????目錄???????????0??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\src\com\googlecode\
?????目錄???????????0??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\src\com\googlecode\bshforandroid\
?????文件????????2772??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\src\com\googlecode\bshforandroid\BshDesc
?????文件????????1079??2015-06-14?06:58??sl4a-master\android\BeanShellForAndroid\src\com\googlecode\bshforandroid\BshInstaller.java
............此處省略14824個文件信息
評論
共有 條評論