首先您可在http://code.google.com/p/iroll/查看iRoll專案,您可選執Dowloads或Source分別下載其執行檔及原始程式。
今天嘗試下載原始程式並利用感知器模擬程式來進行測試。
1. 安裝感測器模擬程式。
2. 修改程式碼。
A. 匯入感知器套件。
import org.openintents.sensorsimulator.hardware.SensorManagerSimulator;
B. 將感知器管理者變數的資料型別從SensorManager改成SensorManagerSimulator
// private SensorManager mySM;
private SensorManagerSimulator mySM;
C. 改寫getSystemService的使用。
// mySM = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mySM = SensorManagerSimulator.getSystemService(this, SENSOR_SERVICE);
D. 增加連線指令(因感測器模擬程式是使用TCP/IP)
mySM.connectSimulator();
F. 記得在AndroidManifest.xml增加使用Internet的選項。
G. 記得在專案的lib檔放入感測器模擬程式所提供的函式庫sensorsimulator-lib.jar,並設定建立程式的相關資訊。
3. 啟動感知器模擬程式。

4. 設定IP。

5. 連線。

6. 執行iRoll程式。



沒有留言:
張貼留言