2013年12月29日 星期日

android WifiManager 的 SSID 双引號疑問?

在android上建立熱點與連上熱點的方法在 google 上查一下就很多了。
這裡提個觀察到的現象,所以只列出重點程式碼。

建熱點時,若名稱為 mynet
WifiConfiguration config = new WifiConfiguration();
config.SSID = "mynet";//注意字串裡沒加双引號

連上熱點如下:
WifiManager wifiManager;
wifiManager.setWifiEnabled(true);
WifiConfiguration wifiConfig;
wifiConfig.SSID = "\"" + "mynet" + "\"";  //注意這邊有加上双引號
int netID = wifiManager.addNetwork(wifiConfig);
wifiManager.enableNetwork(netID, true);

我用2台android設備對連
nexus 7 當客戶端, inhon g1 當熱點

2台設備連線完成,客戶端那一台印出熱點的SSID
Log.e("SSID name: ", wifiManager.getConnectionInfo().getSSID());
nexus 7 印出了 "mynet" ,感覺很正常,因為剛才有加双引號。
接著交換,換 nexus 7 當熱點,inhon g1 當客戶端,
結果印出了 mynet

双引號去那裡了?


2013年10月13日 星期日

Google Play services 安裝問題

打開 android SK Manager 下載了Google Play services.
完成後重新打開Eclipse,呵呵太好了全部的專案都又打上紅叉。
在專案上按右鍵選擇Properties後裡頭的項目,按下去就跳
the currently displayed page contains invalid values. 訊息。

開發android這些年來,老是碰到這種事,真是人生處處皆挫折。

只好再上網查了,應該是adt版本的問題,於是選擇
Help->Install New softwar.
在Work with:選了
ADT Plugin - http://dl-ssl.google.com/android/eclipse/
出現了Developer Tools與NDK Plugins,把它全選然後按NEXT,準備安裝。
接著進Windows->Android SDK Manager.可以看到有些項目可以更新,更新後就正常了。

2013年5月1日 星期三

Android ProGuard問題2

加了 ProGuard 後沒碰到什麼問題,很高興的傳到手機測試,
結果執行到特定的地方就出錯了。
訊息沒留下來,只取了這一小段
ould not find method org.apache.http.params.HttpConnectionParams
是什麼問題呢?弄了老半天也想不出來,整理程式碼時發現
有個程式庫 httpclient-4.1.1.jar ,應該沒使用到吧,於是從專案裡移除,
再重新包成pak,於是就沒問題了,
看來以後沒用到的程式庫還是不要亂加比較好。


2012年6月3日 星期日

Android ProGuard問題


試了 ProGuard 果然遇到問題.

主要的訊息如下:
Proguard returned with error code 1. See console
there were 1290 duplicate class definitions.


google 了一陣子,總算查到解法,主要是在proguard.cfg內加上一行:

-ignorewarnings

就ok了.

另外製作出的apk檔果然小了好多,更方便下載.

2012年4月22日 星期日

一年後的紅叉


Eclipse 專案上出現紅叉的情況有很多,今天又碰到了不一樣的了,原來過了一年就會碰到....,滿有意思的,網路上查了一下;  在 http://developer.android.com/guide/publishing/app-signing.html 內有說明


Expiry of the Debug Certificate

The self-signed certificate used to sign your application in debug mode (the default on Eclipse/ADT and Ant builds) will have an expiration date of 365 days from its creation date.

When the certificate expires, you will get a build error. On Ant builds, the error looks like this:

..............後面還有一些,大意是說刪除 debug.keystore 這個檔案.


想想也接觸 android 一年了...,也沒做什麼好東西出來...唉...


不過我刪除了後...,呃!還是一樣耶...,再查了一下,結果發現把 Thumbs.db 這個檔案也刪掉就好了,過程真是多災多難啊.