Android 模擬 鍵盤 送出 上下左右 指令

利用 sendKeyDownUpSync 模擬使用者按下鍵盤。

	 public boolean KeyUP() {
		 Instrumentation m_Instrumentation = new Instrumentation();
		 m_Instrumentation.sendKeyDownUpSync( KeyEvent.KEYCODE_DPAD_UP );
		 return true;
	 }
	 
	 public boolean KeyDOWN() {
		 Instrumentation m_Instrumentation = new Instrumentation();
		 m_Instrumentation.sendKeyDownUpSync( KeyEvent.KEYCODE_DPAD_DOWN );
		 return true;
	 }
	 
	 public boolean KeyLEFT() {
		 Instrumentation m_Instrumentation = new Instrumentation();
		 m_Instrumentation.sendKeyDownUpSync( KeyEvent.KEYCODE_DPAD_LEFT );
		 return true;
	 }
	 
	 public boolean KeyRIGHT() {
		 Instrumentation m_Instrumentation = new Instrumentation();
		 m_Instrumentation.sendKeyDownUpSync( KeyEvent.KEYCODE_DPAD_RIGHT );
		 return true;
	 }

  2013-06-21      ez      Android
Android 檢查 網路狀態

利用 NetworkInfo 檢查 Android 的網路狀態,並且吐出 JSON 格式。

	public String NetworkInfo() {
		ConnectivityManager CM = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo info = CM.getActiveNetworkInfo();
		if(info!=null)
			return "{ "+
			"getTypeName:\""+info.getTypeName()+"\","+
			"getState:\""+info.getState()+"\","+
			"isAvailable:\""+info.isAvailable()+"\","+
			"isConnected:\""+info.isConnected()+"\","+
			"isConnectedOrConnecting:\""+info.isConnectedOrConnecting()+"\","+
			"isFailover:\""+info.isFailover()+"\","+
			"isRoaming:\""+info.isRoaming()+"\""+
			"}";
		else
			return "{}";
	}

  2013-06-21      ez      Android
Android 檢查 網路是否正常

利用 Ping 的方法檢查網路是否正常!

	public boolean  NetworkIsAccess(){
		 try
	        {
	        	Runtime runtime = Runtime.getRuntime();
	            Process  mIpAddrProcess = runtime.exec("/system/bin/ping -c 1 8.8.8.8");
	            int mExitValue = mIpAddrProcess.waitFor();       
	            return mExitValue==0;            
	        }
	        catch (Exception ex) { }
	        return false;
	}

  2013-06-21      ez      Android
Android 網頁開發 取消 選取框線

Android 開發時遇到,會有自動選取的框線,可以透過 CSS 進行消除!

框線如下圖所示,選擇到某區塊就會出現藍色框線 (不同 Andorid 會有不同顏色):

只需在網頁加上以下 CSS 就可以取消框線:

* 
{
          -webkit-tap-highlight-color: rgba(0, 0, 0, 0);  
}

  2013-06-18      ez      Android
Android Mini PC MK802 開箱

Android Mini PC MK802規格

  • 作業系統:Android 4.0.3
  • 處理器:Allwinner A10 1.5GHz(其實為1GHz的Cortex-A8 1GHz CPU + 0.5GHz 的 GPU)
  • 內建記憶體:DDR3 1GB RAM
  • 儲存空間:4GB
  • 擴充記憶體:MicroSD,最高32GB
  • Wi-Fi無線網路:802.11 b/g
  • 接頭:標準USB(接電腦重灌用)、Mini USB(接鍵盤、滑鼠及USB隨身硬碟)
  • 尺寸:8.8 x 3.5 x 1.2 公分,重量 200公克

外盒看起來還不錯,質感也不錯。


  2012-08-24      ez      Android