首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

Android Platform 3.0 SDK跟Eclipse ADT安装记录五

2012-07-18 
Android Platform 3.0 SDK和Eclipse ADT安装记录五目录:一、在Aptana 3上安装ADT插件二、HTML5教程链接集?--

Android Platform 3.0 SDK和Eclipse ADT安装记录五

目录:

一、在Aptana 3上安装ADT插件

二、HTML5教程链接集

?

--------------------------------------------------

?

一、在Aptana 3上安装ADT插件

?

?

1. ADT插件的更新网址:

https://dl-ssl.google.com/android/eclipse/

?

Android ADT必需的Eclipse插件:

更新仓库在Preferrences->Install/Update->Avalable Software Sites中,默认被屏蔽,需要,勾选它,才可以在Help->Install New Software对话框中看到。第一次刷新列表会很慢。

Eclipse Indigo Update Sitehttp://download.eclipse.org/releases/indigoEnabled

(1) Eclipse Java development tools

(在Programming Languages节点下)

(2) Eclipse Web Developer Tools

(在Web, XML, Java EE and OSGi Enterprise Development节点下)

?

2. 指定Android SDK路径

?

3. 修改.js默认关联编辑器

Preferences->General->Editors->File Associations

默认改为

JavaScript Source Editor

这是Aptana的默认js编辑器,被WDT的js编辑器覆盖了。

?

4. 创建Android工程

?

5. 修改工程属性,增加Web特性

工程->右键->Properties->Project Natures->勾选Web

如果不勾选,Aptana自带的HTML编辑器(非WDT的)的代码提示将失效。

?

6. 添加phonegap支持

(1) 阅读phonegap教程:http://phonegap.com/start#android

(2) 添加phonegap的库(参考phonegap发布包内的例子),修改AndroidManifest.xml,添加一些固定的文件。

?

7. 测试html

(1) 创建html和js文件到assets目录

(2) 在打开html编辑器的情况下按Run按钮,打开本地浏览器(而非Android模拟器),进行本地浏览器(FireFox)测试。

(3) 尝试用Android模拟器运行

(4) Aptana 3对js和html的代码提示和调试功能都比较弱,不过比一般的编辑器要好些。

(5) 简单测试例子(修改自minijoe的测试文件

原始链接:

https://developer.mozilla.org/en/Canvas_tutorial/Basic_animations

我添加了touchmove事件监听器以防止触碰屏幕时卡死界面

?

assets\www\clock.js

?

?

// Simplified version of MDC clock example; original version was published// without explicit copyright notice under the MIT license at// http://developer.mozilla.org/en/docs/Canvas_tutorial:Basic_animationsfunction clock() {  var now = new Date();  var canvas = document.getElementById('canvas');  var ctx = canvas.getContext('2d');  var w = canvas.width;  var h = canvas.height;  ctx.save();  ctx.translate(w / 2, h / 2);  var scale = Math.min(w, h) / 400;  ctx.scale(scale, scale);  ctx.beginPath();  ctx.fillStyle = '#325fA2';  ctx.arc(0, 0, 142 + 6, 0, Math.PI * 2, true);  ctx.fill();  ctx.beginPath();  ctx.fillStyle = '#ffffff';  ctx.arc(0, 0, 142 - 6, 0, Math.PI * 2, true);  ctx.fill();  ctx.rotate(-Math.PI / 2);  ctx.strokeStyle = "black";  ctx.fillStyle = "black";  ctx.lineWidth = 8;  ctx.lineCap = "round";  // Hour marks  for (i = 0; i < 12; i++) {    ctx.save();    ctx.rotate(i * Math.PI / 6);    ctx.fillRect(110, -2, 10, 4);    ctx.restore();  }  // Minute marks  ctx.lineWidth = 5;  for (i = 0; i < 60; i++) {     if (i % 5 != 0) {       ctx.save();       ctx.rotate(i * Math.PI / 30);       ctx.beginPath();       ctx.moveTo(117, 0);       ctx.lineTo(120, 0);       ctx.stroke();       ctx.restore();     }   }  var sec = now.getSeconds();  var min = now.getMinutes();  var hr = now.getHours();  hr = hr % 12;  // write Hours  ctx.save();  ctx.rotate(hr * (Math.PI / 6) + (Math.PI / 360) * min +      (Math.PI / 21600) * sec)  ctx.fillRect(-5, -5, 85, 10);  ctx.restore();  // write Minutes  ctx.save();  ctx.rotate((Math.PI / 30) * min + (Math.PI / 1800) * sec);  ctx.fillRect(-3, -3, 112 + 6, 6);  ctx.restore();  // Write seconds  ctx.save();  ctx.rotate(sec * Math.PI / 30);  ctx.strokeStyle = "#D40000";  ctx.fillStyle = "#D40000";  ctx.lineWidth = 6;  ctx.beginPath();  ctx.moveTo(-30, 0);  ctx.lineTo(83, 0);  ctx.stroke();  ctx.beginPath();  ctx.arc(0, 0, 10, 0, Math.PI * 2, true);  ctx.fill();  // outer circle  ctx.beginPath();  ctx.arc(95, 0, 10, 0, Math.PI * 2, true);  ctx.stroke();  ctx.fillStyle = "#555";  ctx.beginPath();  ctx.arc(0, 0, 3, 0, Math.PI * 2, true);  ctx.fill();  ctx.restore();  ctx.restore();}clock();setInterval(clock, 1000);var touches = []document.body.addEventListener('touchmove', function(event) {event.preventDefault();console.log("touchmove");touches = event.touches;}, false);

?

assets\www\clock.html

?

?

<html>  <head>    <title>Canvsout</title>  </head>  <body>    <canvas id="canvas" width="200" height="200"></canvas>    <script type="text/javascript" src="clock.js"></script>  </body></html>
?

?

AndroidManifest.xml

?

?

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="com.iteye.weimingtom.andhtml"    android:versionCode="1"    android:versionName="1.0" >    <supports-screens        android:anyDensity="true"        android:largeScreens="true"        android:normalScreens="true"        android:resizeable="true"        android:smallScreens="true" />    <uses-permission android:name="android.permission.CAMERA" />    <uses-permission android:name="android.permission.VIBRATE" />    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />    <uses-permission android:name="android.permission.READ_PHONE_STATE" />    <uses-permission android:name="android.permission.INTERNET" />    <uses-permission android:name="android.permission.RECEIVE_SMS" />    <uses-permission android:name="android.permission.RECORD_AUDIO" />    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />    <uses-permission android:name="android.permission.READ_CONTACTS" />    <uses-permission android:name="android.permission.WRITE_CONTACTS" />    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />    <uses-permission android:name="android.permission.GET_ACCOUNTS" />    <uses-permission android:name="android.permission.BROADCAST_STICKY" />    <uses-sdk android:minSdkVersion="10" />    <application        android:icon="@drawable/ic_launcher"        android:label="@string/app_name" >        <activity            android:name=".AndHtmlActivity"            android:label="@string/app_name"             android:configChanges="orientation|keyboardHidden">            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>                <activity            android:name="org.apache.cordova.DroidGap"            android:configChanges="orientation|keyboardHidden"            android:label="@string/app_name" >            <intent-filter>            </intent-filter>        </activity>    </application>    <!--     <uses-sdk android:minSdkVersion="10" />    <application        android:icon="@drawable/ic_launcher"        android:label="@string/app_name" >        <activity            android:name=".AndHtmlActivity"            android:label="@string/app_name" >            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>    </application> -->    </manifest>
?

AndHtmlActivity.java

?

?

package com.iteye.weimingtom.andhtml;import org.apache.cordova.DroidGap;import android.os.Bundle;public class AndHtmlActivity extends DroidGap {    /** Called when the activity is first created. */    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        super.loadUrl("file:///android_asset/www/clock.html");    }}
?

?

------------------------------

?

?

二、HTML5教程链接集

1.?Canvas tutorial - MDN

可能有些内容特定于FireFox,但大部分例子应该也可用于Android手机上(可能需要一些修改,见上)

https://developer.mozilla.org/en/Canvas_tutorial

?

2.?Sony Ericsson WebSDK Packager

PhoneGap官方推荐的工具,提供一个AIR模拟器(需要预先安装AIR运行时)和几个示例(都是基于PhoneGap)

http://developer.sonymobile.com/wportal/devworld/technology/other/web/websdkpackager

?

3. Cross-platform Development with PhoneGap

webos的官方PhoneGap例子

https://developer.palm.com/content/resources/develop/cross_platform_development.html

?

4.?Web App Samples

Tizen官方提供的开源游戏示例(完整的游戏,比较复杂,有些是基于jquery的,推荐)

https://developer.tizen.org/resources/sample-web-applications

?

5. Windows Phone界面的网页Demo

http://m.microsoft.com/windowsphone/en-us/demo/default.aspx

?

6.?Getting Started (CSS Tutorial)

MDN的CSS教程

https://developer.mozilla.org/en/CSS/Getting_Started

?

7.?Making Isometric Real-Time Games with HTML5, CSS3 and Javascript

HTML5网页游戏开发

http://shop.oreilly.com/product/0636920020011.do

https://github.com/andrespagella/Making-Isometric-Real-time-Games

?

8.?Arctic.js

http://dev.classmethod.jp/smartphone/as3-like-coding-arctic-js/

https://github.com/DeNADev/Arctic.js

?

9.?ActionScript入門Wiki

关于HTML5 Canvas和第三方JavaScript库的教程(日文)

http://www40.atwiki.jp/spellbound/pages/1779.html

?

10.?Learn HTML5, CSS3, Javascript - video style tutorials | TheCodePlayer

HTML5教程,可观看录像演示

http://thecodeplayer.com/

http://www.iteye.com/news/25389

?

----------------------------------

?

三、PhoneGap全屏问题

?

在调用loadUrl之前执行:

?

?

        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);             requestWindowFeature(Window.FEATURE_NO_TITLE);            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,         WindowManager.LayoutParams.FLAG_FULLSCREEN);  

?

参见:

http://blog.csdn.net/webdisk008/article/details/6701967

http://bbs.phonegapcn.com/thread-989-1-1.html

?

?

?

?

?

?

(TODO)

?

热点排行