Pages

Subscribe:

Ads 468x60px

Labels

顯示具有 Android 標籤的文章。 顯示所有文章
顯示具有 Android 標籤的文章。 顯示所有文章

2013年10月19日 星期六

密碼錢包程式 空中簽名防破解

(中央社記者許秩維台北14日電)用手機收信、登入網銀雖然方便,卻有被破解或入侵危險。交大團隊研發「密碼錢包」程式,用空中簽名辨識,讓資安有保障。
世新大學今天舉行「大文山APP園區啟用典禮暨2013雲端創新應用服務競賽活動頒獎典禮」,全國第一個由產官學合作的「大文山APP園區」,將投入APP應用程式研發與人才培育。
世新大學表示,大文山APP園區目前設有「潛能開發區」、「創意交流區」及「開放空間討論區」等主題,將結合跨領域的學生或社會人士團隊,並邀業界師資講授專業課程,幫助團隊在園區完成創意發想、執行開發,希望成為年輕人創業的敲門磚。
世新大學傳播管理系學生林鈺婷研發「Easy watchEasy buy」,結合偶像劇與線上購物,方便用戶選購偶像劇內的商品,獲雲端創新應用競賽創意發想組冠軍。交通大學資訊工程研究所博士候選人陳柏愷與碩士生蔡孟勳研發「AirSig密碼錢包」,則獲應用開發組冠軍。
陳柏愷表示,用手機登入電子信箱、網路銀行等,都得輸入密碼,為防止被破解、入侵,因此開發3D空中簽名技術,使用者完成設定後,以拇指按住手機螢幕,想像手機左上角為筆尖,在空中簽名,通過驗證後,就可登入帳號,目前已能在Google Play免費下載。1021014

谷歌推新輸入法 幫修注音文

(中央社記者吳佳穎台北2013年10月17日電) Google今日推出支援Android 2.3.3 以上的「Google注音輸入法」,能智慧校正;若偷懶打「ㄐㄊㄊㄑㄅㄘ」的「注音文」,會智慧校正成「今天天氣不錯」,更省時方便。
Google台灣分公司表示,只要是Android 2.3.3 以上的智慧型手機及平板電腦,都可到Google Play應用程式商店下載「Google注音輸入法」。
「Google注音輸入法」採用先進的注音輸入法引擎,提供使用者「注音字首整句輸入」、「詞句預測智慧校正」及「快捷輸入字母符號」等功能。
「注音字首整句輸入」還讓使用者只要打句子中每個字的第一個注音符號,「Google注音輸入法」就會自動根據語意完成一長串的句子。例如,打「ㄐㄊㄊㄑㄅㄘ」就能智慧輸入「今天天氣不錯」,更省時簡便,不用擔心打出「注音文」。
Google台灣分公司說,使用新的注音輸入法,不小心打錯字也沒關係,「詞句預測智慧校正」會補上正確的字供選。
另有快捷輸入,只要按住按鍵向下滑,就能直接輸入數字、英文字母或是標點符號,不需繁瑣地切換至符號頁面;也內建有豐富的「顏文字」,有各種表情符號,只要按一鍵,就能搞定要表達的喜怒哀樂。

行動比爾APP 繳費真輕鬆

工商時報【黃台中】
行動繳款服務又見創新型態!工研院開發出「行動比爾」APP,推出創新便民行動繳費機制,民眾只要下載APP並通過發帳單位認證,就可以輕鬆透過手機取得各項電子帳單服務,持「行動比爾APP」所產生的帳單條碼,到全家便利商店服務櫃檯刷取條碼繳費,除了免紙的便利與環保,透過全家便利商店在收費上更多了一層交易保障。
即日起,民眾只要持「行動比爾APP」到全家便利商店,首刷捐款給家扶基金會、或繳交水費,就可以獲得全家30元的現金回饋。
開發「行動比爾APP」的工研院資通所所長吳誠文表示,「行動比爾APP」目前已整合台水公司繳費及捐款給家扶基金會的服務,這項服務根據不同尺寸及解析度智慧型手機產生便利商店可正確讀取之最相容條碼的專利技術,結合便利商店的收款機制,方便民眾運用行動通訊裝置進行金流服務,持有支援作業系統iOS及Android2.2以上的智慧型手機都可以免費下載安裝使用。
台水公司副總經理籃炳樟表示,智慧型手機APP繳水費服務,取代傳統的紙本帳單,民眾只要以手機螢幕顯示的條碼到超商就能繳費,103年底前申辦電子帳單選擇免寄紙本的民眾,享有每期水費減收3元的優惠。

2013年7月23日 星期二

An Easy Link between Arduino and Android

Annikken Andee is an Arduino Shield that lets you connect your Arduino to your Android phone via bluetooth easily. With the free Annikken Andee Library and Android App, you can create your very own monitor and control user interface on your Android Devices from the Arduino IDE. This simply means you are NOT required to develop any Android Apps at all.

Works with Arduino


Annikken Andee is designed to fit and work with Arduino Uno, Arduino Mega and Arduino Leonardo. For variants like Arduino Nano, you will have to connect the ICSP header correctly and also pin 8 together. Support for other Arduinos (e.g Due) are still currently being tested.
Annikken Andee and Arduino communicates using Arduino's ICSP header (SPI) and pin 8, leaving the rest of the pins for connection with other sensors or modules. Refer to manual for details.

Code in Arduino - Create Android Interface


Annikken Andee differentiates itself from other bluetooth shields by allowing Arduino developers to have an touch and display Android interface with NO NEED for any Android development effort.
Andee Library  
Instead of providing Android project samples which you need to modify and adapt to your application, we give you an Android App and a Annikken Andee library for Arduino. What this means is that you will be using the easy to use Arduino environment to create data displays or buttons on the Android App - as shown above.

Wireless Bluetooth Data Transmission

Bluetooth Logo FCC CE logo
Annikken Andee and the Android app communicates using the FCC CE certified WT11i bluetooth module from Bluegiga. This module is capable of reaching distances of up to 350 meters line-of-sight module-to-module. (For actual distance, it depends on the bluetooth chip of your Android device and also how/where Annikken Andee is being positioned.)

Types of Android Displays

There are three types of displays you can create on the Android App with colors you can customize using argb values. Displays can be configured to occupy quarters, thirds, half or full width of your Android screen.
  • Data Displays
    These are displays used for providing user with feedback. Up to 3 text fields each display which you can choose to display any text or numbers you want.
  • Data Display Screenshot Code Snippet
  • Button Displays
    These displays catch user inputs from Android user. Your Arduino code can call a function to find out if the button was pressed or not, and perform handling functions from there on.
  • Button Displays Code Snippet
  • Keyboard Displays
    Similar to button displays. Shows the Android keyboard for users to enter text, numbers or password. Arduino can retrieve this value using a function call.
  • Keyboard displays Code Snippet

Onboard SD Card

SD Card SlotSD Card Code Example
Annikken Andee provides an sd card slot for use a non-volatile data storage. You can use it to write log data from your Arduino application. For ease of use, we provide read and write functions from Annikken Andee library for Arduino. In addition, you can use an sdcard to upgrade Annikken Andee's firmware with the latest images to ensure you get the most recent features.

Reviewing Numeric Data Using Graph

landscape Analog andee graph
If you data happens to be numeric, our Annikken Andee App is able to collect the data and plot a graph for it. This helps you to visualize numerical data for analytical purposes.

Use Phone Functions From Arduino

When your Android phone is connected to Annikken Andee + Arduino, you can write code (in Arduino) to:
  • Send SMS to a recipient
  • Vocalize using Text-to-Speech
  • Create a notification on Android

2013年6月17日 星期一

【公告】102年度中區委外職前訓練計畫招生中

主辦單位:行政院勞工委員會職業訓練局中區職業訓練中心
培訓單位:僑光科技大學
招訓對象: 失業民眾(報名參訓須以結訓後直接就業為目標,無就業意願或有升學計畫者請勿報名)
訓練日期:1020626 ~ 1021004(共360小時)
上課時間:週一至週五:早上09001200,下午13001600,每日共6
上課地點:僑光科技大學(台中市西屯區僑光路100號)
招訓人數:30人
課程內容:
開訓、結訓/兩性平等教育/職場倫理/就業市場趨勢分析/求職技巧/Linux引論&作業系統應用/C語言程式設計/
數位電路設計/自動控制液氣壓原理與元件介紹/機器手臂操作與應用/NXT-G程式設計/4各種機器人實例操作/
無線自動化控制與設計/專題製作
報名時間:即日起至102/6/23日截止,並於102年06月24日下午13:30辦理甄試












報名方式:
1、職訓e網線上報名 http://163.29.199.215/index.html
2、僑光科大推廣教育中心「最新公告」下載報名表
       (親送本中心報名或傳真報名04-2707314或mail至eec@ocu.edu.tw並請來電確認!!)
詳情請參見簡章說明,謝謝!

2013年6月15日 星期六

Stencyl:不懂程式也能寫 iOS 智慧型手機遊戲!

如果是要探討「不會寫程式也能寫遊戲」這種主題的話,像是 RPG 遊戲製作大師、 GAME MAKER 等軟體都可做到。但是如果說製作好的遊戲,不但可以發布成 Flash 的 .swf 檔,甚至還可以發布到 iOS 平台上,那就是 Stencyl 的強項了,未來也可以支援 Android 與 Html5 版本呢!
Stencyl 網址:
Stencyl 強調可輕鬆的製作 iOS 與 Flash 遊戲(未來將會支援 Android 與 html5),甚至不需要會寫程式也能製作遊戲。目前支援在 OS X、Windows 以及 Ubuntu 平台上製作,免費版僅能產生 Flash 的 .swf 檔,如果要產生一般的桌面程式檔案就得付費了,一年的授權是 79 美金(大約 2100 台幣),而如果你要能夠產生能在 iOS 平台上架的話,一年的授權是 149 美金(大約 4500 台幣左右)。以下為筆者簡單的試玩心得。
 
▲ 網站首頁標明了特色,輕鬆的製作 iOS 與 Flash 遊戲!(未來將會支援 Android 與 html5)
 
▲ 免費版僅能產生 Flash 的 .swf 檔,如果要產生一般的桌面程式檔案就得付費了,一年的授權是 79 美金(大約 2100 台幣),而如果你要能夠產生能在 iOS 平台上架的話,一年的授權是 149 美金(大約 4500 台幣左右)。
▲ 將程式免費下載及安裝好後,可以看到在程式的首頁有許多內建的範例與一些已經幫你做好的行為模組。
▲ 這邊是內建的一些範例
▲ 亦有內建好的一些行為模組,可以讓你直接套用不需自己重新刻。
▲ 你也可以點進行為模組,可以看到完整的程式碼,也可以讓你自己調整,或是自己重新設計一個,Scratch-like 的積木設計十分友善。
▲ 場景編輯器有圖層、元件,也可以用內建的場景編輯器自己畫一個。(以下都用內建的 Crash Course Kit 這個來示範。)
▲ 也有兩個角色讓你用,當然也可以自訂,輸入圖像。
▲ 要將行為模組掛上角色也非常方便,直接在行為模組上點右鍵選「Attach Behavior to Actor」,在這邊我們用 Walking 作個示範。
▲ 點了「Attach Behavior to Actor」後就可以選擇你要掛上這個行為模組的角色。
▲ 點擊後就進入設定畫面,首先要設定在「Walking」中有定義的向左走與向右走的按鍵。
▲ 接著設定在 Walking 模組中程式定義的圖像,在這個範例中有左、右、行動中往左、行動中往右。
▲ 製作完畢後在場景中新增角色,然後按「Ctrl+ENTER」就可以測試一番了,試試看往左往右吧!想要輸出選上方「Publish」後選擇 Flash(免費版僅能如此)
製作完成的範例:點我下載
玩了一會,覺得 Stencyl 使用起來較 GameMaker 等軟體來說更為進階,可以設計更深的行為與事件,也可以自己全部重刻。當然最大的賣點還是只要製作好後可以輸出多個平台的功能,期待日後支援 Android 與 HTML5 的到來,那時才更方便測試多平台的支援度。

2013年6月3日 星期一

7种形式的Android Dialog使用举例

在Android开发中,我们经常会需要在Android界面上弹出一些对话框,比如询问用户或者让用户选择。这些功能我们叫它Android Dialog对话框,在我们使用Android的过程中,我归纳了一下,Android Dialog的类型无非也就7种,下面我分别向大家介绍这7种Android Dialog对话框的使用方法,希望对大家能有所帮助。
1.该效果是当按返回按钮时弹出一个提示,来确保无误操作,采用常见的对话框样式。
创建dialog对话框方法代码如下:
protected void dialog() {
    AlertDialog.Builder builder = new Builder(Main.this);
    builder.setMessage("确认退出吗?");
    builder.setTitle("提示");
    builder.setPositiveButton("确认", new OnClickListener() {
     @Override
     public void onClick(DialogInterface dialog, int which) {
      dialog.dismiss();
      Main.this.finish();
     }
    });
    builder.setNegativeButton("取消", new OnClickListener() {
     @Override
     public void onClick(DialogInterface dialog, int which) {
      dialog.dismiss();
     }
    });
    builder.create().show();
   }
在onKeyDown(int keyCode, KeyEvent event)方法中调用此方法 
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
     dialog();
    }
    return false;
   }
2.改变了对话框的图表,添加了三个按钮
创建dialog的方法代码如下:
Dialog dialog = new AlertDialog.Builder(this).setIcon(
       android.R.drawable.btn_star).setTitle("喜好调查").setMessage(
       "你喜欢李连杰的电影吗?").setPositiveButton("很喜欢",
       new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
         // TODO Auto-generated method stub
         Toast.makeText(Main.this, "我很喜欢他的电影。",
           Toast.LENGTH_LONG).show();
        }
       }).setNegativeButton("不喜欢", new OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which) {
       // TODO Auto-generated method stub
       Toast.makeText(Main.this, "我不喜欢他的电影。", Toast.LENGTH_LONG)
         .show();
      }
     }).setNeutralButton("一般", new OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which) {
       // TODO Auto-generated method stub
       Toast.makeText(Main.this, "谈不上喜欢不喜欢。", Toast.LENGTH_LONG)
         .show();
      }
     }).create();
     dialog.show();
3.信息内容是一个简单的View类型
创建dialog方法的代码如下:
new AlertDialog.Builder(this).setTitle("请输入").setIcon(
       android.R.drawable.ic_dialog_info).setView(
       new EditText(this)).setPositiveButton("确定", null)
       .setNegativeButton("取消", null).show();
4.信息内容是一组单选框
创建dialog方法的代码如下:
new AlertDialog.Builder(this).setTitle("复选框").setMultiChoiceItems(
       new String[] { "Item1", "Item2" }, null, null)
       .setPositiveButton("确定", null)
       .setNegativeButton("取消", null).show();
5.信息内容是一组多选框
创建dialog方法的代码如下:
new AlertDialog.Builder(this).setTitle("单选框").setIcon(
       android.R.drawable.ic_dialog_info).setSingleChoiceItems(
       new String[] { "Item1", "Item2" }, 0,
       new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
         dialog.dismiss();
        }
       }).setNegativeButton("取消", null).show();
6.信息内容是一组简单列表项
创建dialog的方法代码如下:
new AlertDialog.Builder(this).setTitle("列表框").setItems(
       new String[] { "Item1", "Item2" }, null).setNegativeButton(
       "确定", null).show();
7.信息内容是一个自定义的布局
dialog布局文件代码如下:

  
   
   
  
创建dialog方法的代码如下: 
LayoutInflater inflater = getLayoutInflater();
     View layout = inflater.inflate(R.layout.dialog,
       (ViewGroup) findViewById(R.id.dialog));
     new AlertDialog.Builder(this).setTitle("自定义布局").setView(layout)
       .setPositiveButton("确定", null)
       .setNegativeButton("取消", null).show();
好了,以上7种Android dialog对话框的使用方法就介绍到这里了,基本都全了,如果大家在android开发过程中遇到dialog的时候就可以拿出来看看。
另外注,本文参考文章: 
http://android.tgbus.com/Android/tutorial/201107/359812.shtml

Ken Yang 筆記: Arduino bluetooth

Ken Yang 筆記: Arduino bluetooth: 先前講過arduino的基本介紹, 這篇要講如何綁上bluetooth shield到arduino上面! 首先要先介紹bluetooth shield上的pin腳, 先看到下圖,下圖中右邊有一排pin腳, 主要會用到前面4隻pin腳, 而4隻pin腳依序為: ...

Ken Yang 筆記: Arduino 基本教學

Ken Yang 筆記: Arduino 基本教學: Arduino 是一塊Open Source電路板, 開發者可以利用這塊板子去做到一些電子器材的控制, 例如:開燈、關燈,甚至可以在Arduino上裝上sensor, 然後根據sensor的資料來做處理!例如接上了光敏電阻這個sensor, 我們就可以判斷目前光的亮度,就...

用 Android 手機透過藍牙與 Arduino 溝通(二)

在上一篇已經準備好了 Android App 程式(MultiColor Lamp)﹐並且把 Bluetooth 模組的 Baud rate 也設置好了﹐接下來我們要把各項組合起來﹐這裏我使用的 bluetooth 模組是用 XBee 型式的。
在開始之前要先把 sketch 程式寫到 arduino ATmega 328 中(sketch 在所下載的 MultiColorLamp.zip 之中)﹐在寫入之前最好將arduino 板子上的東西都先移除﹐才不會出現干擾。
MultiColorLamp_pde
接下來就要開始將必要的線路全部接上
arduino_Moto_led

由上圖﹐在麵包板上插上三個 Led 燈﹐紅﹑綠﹑黃﹐並分別將三個 Led的正極接腳接到Xbee 傳感器擴展板V5的 9,10,11 腳位﹐負極則接到 GND 的位置﹐這樣就一切就緒了。
現在一切都俱備﹐只要將 Arduino 接上USB就可以了﹐在影片上可以看到當 arduino 接上USB 之後﹐過一會三個燈會全部亮起來﹐這是因為在 sketch 中 setup() 時把腳位都設為 HIGH﹐所以一開始三顆燈都亮了。而在手機的藍牙連線上後可能會全部熄滅(因為在 Android App 程式的 OnStart 中會先讀取在上一次App程式離開前所儲存的數值)﹐接著就可以用手機來控制燈號。


根據上述的程式﹐只要把 sketch 程式稍微修改﹐再搭配電機﹑馬達就可以遙控小車了。這裏把原本做避障的小車稍微修改原本的 sketch 程式就能遙控了﹐不過這是拿原本的 sketch 程式修改搭配原本的 App程式﹐操控上不是很好﹐不過現在只是先讓藍牙溝通沒問題﹐下次再找時間好好的根據所要的性能來撰寫程式了。

Ken Yang 筆記: Android Bluetooth API

Ken Yang 筆記: Android Bluetooth API: 這篇主要教大家怎麼用Bluetooth API去 搜尋裝置 連結 裝置 傳送指令至裝置上 首先要先宣告下列三個物件與常數, private static BluetoothAdapter mBluetoothAdapter = null; // 用來搜尋、管理藍...

Android Bluetooth API 使用心得筆記

1.Bluetooth基本概念
可以參考BlueCove這個實作JSR82的Project,裡面的這張圖對Bluetooth解說很清楚,可供參考。

Bluetooth Stack的部份在不同系統、程式語言上都是相同的,會有差異的只有頂層的Abstract API。

若想對Bluetooth整體軟硬体有仔細的了解可以參考「Bluetooth Application Programming with the Java APIs Essentials Edition」這本書。

2.Android Bluetooth開發基本需求
Android SDK 2.0以上(含2.0)版本。
支援Android 2.0的手機一隻(Android Emulater無法模擬Bluetooth,所以一定要有實體手機)。

3.實作參考文件
http://developer.android.com/guide/topics/wireless/bluetooth.html
http://www.anddev.org/serial_over_bluetooth_simple_test_client-t11106.html

一般來說,我們只會實作Bluetooth Client的程式去跟其它的Bluetooth硬體溝通取資料。連線方式大多是利用Serial Port Service方式去跟遠端的裝置溝通,所以相對應的UUID不能設錯,一定要設成下述範例這組UUID,不然會發生找不到Service的問題(附帶一提,這是假設一般遠端裝置有提供Serial Port Service,所以你才可以用這組UUID來進行通訊,如果遠端裝置比較特別就要去查硬體規格去看它提供的Service是哪些,找出對應的UUID)。

1
private static final UUID SERIAL_PORT_SERVICE_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");


4.Android Bluetooth API目前的限制
目前只支援RFCOMM的方式進行通訊

5.實作參考範例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// 取自http://www.anddev.org/serial_over_bluetooth_simple_test_client-t11106.html裡的範例
package  com.example.thinbtclient;
 
import java.io.IOException;
import java.io.OutputStream;
import java.util.UUID;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
 
public class ThinBTClient extends Activity {
     
     private static final String TAG = "THINBTCLIENT";
     private static final boolean D = true;
     private BluetoothAdapter mBluetoothAdapter = null;
     private BluetoothSocket btSocket = null;
     private OutputStream outStream = null;
     // Well known SPP UUID (will *probably* map to
     // RFCOMM channel 1 (default) if not in use);
     // see comments in onResume().
     private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
 
     // ==> hardcode your server's MAC address here <==
     private static String address = "XX:XX:XX:XX:XX:XX";
 
     /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
 
          if (D)
               Log.e(TAG, "+++ ON CREATE +++");
 
          mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
          if (mBluetoothAdapter == null) {
               Toast.makeText(this,
                    "Bluetooth is not available.",
                    Toast.LENGTH_LONG).show();
               finish();
               return;
          }
 
          if (!mBluetoothAdapter.isEnabled()) {
               Toast.makeText(this,
                    "Please enable your BT and re-run this program.",
                    Toast.LENGTH_LONG).show();
               finish();
               return;
          }
 
          if (D)
               Log.e(TAG, "+++ DONE IN ON CREATE, GOT LOCAL BT ADAPTER +++");
     }
 
     @Override
     public void onStart() {
          super.onStart();
          if (D)
               Log.e(TAG, "++ ON START ++");
     }
 
     @Override
     public void onResume() {
          super.onResume();
 
          if (D) {
               Log.e(TAG, "+ ON RESUME +");
               Log.e(TAG, "+ ABOUT TO ATTEMPT CLIENT CONNECT +");
          }
 
          // When this returns, it will 'know' about the server,
          // via it's MAC address.
          BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
 
          // We need two things before we can successfully connect
          // (authentication issues aside): a MAC address, which we
          // already have, and an RFCOMM channel.
          // Because RFCOMM channels (aka ports) are limited in
          // number, Android doesn't allow you to use them directly;
          // instead you request a RFCOMM mapping based on a service
          // ID. In our case, we will use the well-known SPP Service
          // ID. This ID is in UUID (GUID to you Microsofties)
          // format. Given the UUID, Android will handle the
          // mapping for you. Generally, this will return RFCOMM 1,
          // but not always; it depends what other BlueTooth services
          // are in use on your Android device.
          try {
               btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);
          } catch (IOException e) {
               Log.e(TAG, "ON RESUME: Socket creation failed.", e);
          }
 
          // Discovery may be going on, e.g., if you're running a
          // 'scan for devices' search from your handset's Bluetooth
          // settings, so we call cancelDiscovery(). It doesn't hurt
          // to call it, but it might hurt not to... discovery is a
          // heavyweight process; you don't want it in progress when
          // a connection attempt is made.
          mBluetoothAdapter.cancelDiscovery();
 
          // Blocking connect, for a simple client nothing else can
          // happen until a successful connection is made, so we
          // don't care if it blocks.
          try {
               btSocket.connect();
               Log.e(TAG, "ON RESUME: BT connection established, data transfer link open.");
          } catch (IOException e) {
               try {
                    btSocket.close();
               } catch (IOException e2) {
                    Log.e(TAG,"ON RESUME: Unable to close socket during connection failure", e2);
               }
          }
 
          // Create a data stream so we can talk to server.
          if (D)
               Log.e(TAG, "+ ABOUT TO SAY SOMETHING TO SERVER +");
 
          try {
               outStream = btSocket.getOutputStream();
          } catch (IOException e) {
               Log.e(TAG, "ON RESUME: Output stream creation failed.", e);
          }
 
          String message = "Hello message from client to server.";
          byte[] msgBuffer = message.getBytes();
          try {
               outStream.write(msgBuffer);
          } catch (IOException e) {
               Log.e(TAG, "ON RESUME: Exception during write.", e);
          }
     }
 
     @Override
     public void onPause() {
          super.onPause();
 
          if (D)
               Log.e(TAG, "- ON PAUSE -");
 
          if (outStream != null) {
               try {
                    outStream.flush();
               } catch (IOException e) {
                    Log.e(TAG, "ON PAUSE: Couldn't flush output stream.", e);
               }
          }
 
          try  {
               btSocket.close();
          } catch (IOException e2) {
               Log.e(TAG, "ON PAUSE: Unable to close socket.", e2);
          }
     }
 
     @Override
     public void onStop() {
          super.onStop();
          if (D)
               Log.e(TAG, "-- ON STOP --");
     }
 
     @Override
     public void onDestroy() {
          super.onDestroy();
          if (D)
               Log.e(TAG, "--- ON DESTROY ---");
     }
}
 
AndroidManifest.xml裡的Permission設定加下述二行
"android.permission.BLUETOOTH_ADMIN"
/> "android.permission.BLUETOOTH" />

Android SDK 2.1裡的Bluetooh Sample (在 x:/android sdk安裝目錄/platforms/android-2.1/samples/BluetoothChat 裡面,或是到 http://developer.android.com/resources/samples/BluetoothChat/index.html 看範例,二者是一樣的東西)

http://code.google.com/p/apps-for-android/ 裡面有個 BTClickLinkCompete Sample,可經由SVN去下載回來看 


資料來源

2013年5月28日 星期二

Notepad2-mod

Arduino常用的程式碼編寫工具


我先說一下我選程式編寫器的要求:
1、有語法highlight
功能,這是必須的。
2、軟體要輕量,介面要簡潔,可以一下子打開很多個視窗方便編輯。好像UltraEdit這樣的介面太複雜了,很多時候功能用不到,而vc++又打開極其緩慢,浪費時間。
3、相容中文注釋,其實這個要求不是重點,只是ArduinoIDE竟然不支持,所以才作為要求。
4、可以把語法highlight
方案匯出為 HTMLUBB 代碼,便於論壇或者網站分享。
5、字體清晰可見,必須是等寬字體,中文必須方正,選擇時候不能像一些相容中文的外國軟體,因為字體沒選好,選擇文本時候會選到半個中文字這樣。



最後選擇了Notepad2 MOD


檔案下載






会走会打自己的 ANDROID 垃圾桶机械人自己做(视频)


上面这台Android 机械人是由一位 Android 手机的用家在心血来潮时制成呢!从外观说起,标题叫它做 Android 垃圾桶不是毫无根据的;顾名思义,这机械人的头部和身躯都是以垃圾桶作为基础,内藏 Anduino 机板。Android 绿是自行喷上去的,而双手就是由水管切割而成,会上下左右地举,还懂敲打自己的头部和身躯,真可爱。至于它的「腿」则变成了两个左右的主轮和前后的辅助轮,不然站不稳呢。
或许读者们也会留意到它的肚子有一个显示器和四个像炮口的东西,据制造者所说,这是为了做到手动和全自动操作而安装的 LCD 显示器和超音波距离传感器喔;只是我们未能在影片中确认哪些操作属自动。另外有趣的是,机械人在影片的后段因为突如其来的停步而跌到头部和身躯分离呢!(制造者用了一个更生动的动词,只是小编不方便放上来啦)其后我们会看到它的内部构造,血管和器官电线和零件比想象中多,幸好机械人在站起来后运作正常,没有疯狂起来。
制造者在论坛的帖子上极之详细地纪录了这机器的制作过程,还附有大量图片。对这部机械人感兴趣的读者绝对不能错过!另一张图片和影片在继续阅读里。