2013年11月11日 星期一
iOS推播 一行產生推播pem檔
openssl pkcs12 -in aps_development.p12 -out aps_development.pem -nodes -clcerts -password pass:''
2013年10月22日 星期二
Java json parser
https://code.google.com/p/json-simple/
example:
JSONObject jsonObj = (JSONObject) JSONValue.parse(json_string);
JSONArray jsonArray = (JSONArray) jsonObj.get("key");
example:
JSONObject jsonObj = (JSONObject) JSONValue.parse(json_string);
JSONArray jsonArray = (JSONArray) jsonObj.get("key");
2013年10月17日 星期四
2013年10月2日 星期三
2013年8月22日 星期四
Objective-C 禁用UDID 替代方案:OpenUDID
優缺點分析參考文章:http://www.alexplay.tw/2013/03/udid.html
https://github.com/ylechelle/OpenUDID
取得OpenUDID方式:
#include "OpenUDID.h"
NSString* openUDID = [OpenUDID value];
Objective-C ARC 專案中使用非ARC Code
在build Phases ->Compile Sources找到非ARC code
在Compiler Flags加上: -fno-objc-arc
在Compiler Flags加上: -fno-objc-arc
2013年7月3日 星期三
Android Error : INSTALL_FAILED_INSUFFICIENT_STORAGE
INSTALL_FAILED_INSUFFICIENT_STORAGE
2013年6月19日 星期三
Objective-C 祕技:撥完電話回到APP,讓你不會回不去。
Jie的懶教學,今天來告訴大家一個祕技:
Objective-C 呼叫電話撥號功能通常都會使用:tel
若改成:telprompt
瑞凡,我可以回去了!
懶人就是要一行就搞定~完工,爆肝!
Objective-C 呼叫電話撥號功能通常都會使用:tel
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",@"0928123123"]]];
但播完就會停留在電話程式裡...若改成:telprompt
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"telprompt:%@",@"0928123123"]]];
結束就可以回到原本的APP畫面,瑞凡,我可以回去了!
懶人就是要一行就搞定~完工,爆肝!
2013年6月18日 星期二
Objective-C Custom Cell,可以使用覆寫prepareForReuse方法清除舊資料再利用
-(void)prepareForReuse{
[super prepareForReuse];
//清除舊資料
delegate = nil;
}
2013年6月14日 星期五
Objective-C 開啓 Google Map App 並帶入經緯度查詢
Jie的懶教學,來教大家用 Objective-C 開啓 Google Map App 並帶入經緯度查詢:
其他進一步設定可以參考:https://developers.google.com/maps/documentation/ios/urlscheme?hl=zh-TW
完工,爆肝。
//檢查有無安裝google map
if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"comgooglemaps://"]]){
//開啓Google Map App
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"comgooglemaps://?saddr=%f,%f&daddr=%f,%f&directionsmode=walking",起點latitude,起點longitude,終點latitude,終點longitude]]];
}else{
//開啟網頁版Google Map(太簡單,略)
}
其他進一步設定可以參考:https://developers.google.com/maps/documentation/ios/urlscheme?hl=zh-TW
完工,爆肝。
2013年6月13日 星期四
2013年6月10日 星期一
Jie的懶教學:Android Http通訊協定資料存取 (GET,POST)
Jie的懶教學,這次來教大家來寫一隻Android的懶人HttpClient程式:
在Android使用Http通訊協定(GET,POST)讀取網頁或做資料存取的時候,
每次都要做一堆try catch處理。
POST的時後設定的NameValuePair形態使用也不太習慣,
基本上POST的形態都是字串,所以接口乾脆直接改成用HashMap<String,String>來設定感覺比較親切些。
當然最重要的原因還是懶,懶人就是要想盡辦法一行就搞定:D
懶人前:
懶人後:
回傳的result字串可能是HTML,XML或JSON,就視狀況去處理啦~
完工,爆肝。
每次都要做一堆try catch處理。
POST的時後設定的NameValuePair形態使用也不太習慣,
基本上POST的形態都是字串,所以接口乾脆直接改成用HashMap<String,String>來設定感覺比較親切些。
當然最重要的原因還是懶,懶人就是要想盡辦法一行就搞定:D
懶人前:
package com.example.jiehttpclient;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class JieHttpClient {
public static String GET(String url){
String result = "";
HttpGet get = new HttpGet(url);
try {
HttpClient httpClient = new DefaultHttpClient();
HttpResponse httpResponse = httpClient.execute(get);
if(httpResponse.getStatusLine().getStatusCode()== HttpStatus.SC_OK){
result = EntityUtils.toString(httpResponse.getEntity());
}else{
result = "JieHttpClient GET Fail";
}
}catch(ClientProtocolException e){
System.out.println("JieHttpClient GET Error = "+e.getMessage().toString());
}catch (IOException e){
System.out.println("JieHttpClient GET Error = "+e.getMessage().toString());
}catch (Exception e){
System.out.println("JieHttpClient GET Error = "+e.getMessage().toString());
}
return result;
}
public static String POST(String url,HashMap<String,String> paramsMap){
String result = "";
HttpPost post = new HttpPost(url);
try {
if(paramsMap!=null){
List<NameValuePair> params = new ArrayList<NameValuePair>();
for(Map.Entry<String,String> entry:paramsMap.entrySet()){
params.add(new BasicNameValuePair(entry.getKey(),entry.getValue()));
}
HttpEntity httpEntity = new UrlEncodedFormEntity(params,"utf-8");
post.setEntity(httpEntity);
}
HttpClient httpClient = new DefaultHttpClient();
HttpResponse httpResponse = httpClient.execute(post);
if(httpResponse.getStatusLine().getStatusCode()== HttpStatus.SC_OK){
result = EntityUtils.toString(httpResponse.getEntity());
}else{
result = "JieHttpClient POST Fail";
}
}catch(ClientProtocolException e){
System.out.println("JieHttpClient POST Error = " + e.getMessage().toString());
}catch (IOException e){
System.out.println("JieHttpClient POST Error = " + e.getMessage().toString());
}catch (Exception e){
System.out.println("JieHttpClient POST Error = " + e.getMessage().toString());
}
return result;
}
}
懶人後:
//GET
String result = JieHttpClient.GET("GET URL");
//POST
HashMap<String,String> params = new HashMap<String, String>();
params.put("key1","value1");
params.put("key2","value2");
String result = JieHttpClient.POST("POST URL",params);
回傳的result字串可能是HTML,XML或JSON,就視狀況去處理啦~
完工,爆肝。
2013年6月7日 星期五
Android 專案需要網路請求時要記得加上 INTERNET Permission
在AndroidManifest.xml裡加上:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.INTERNET" />
Android 專案拿掉 TitleBar 的方法
修改AndroidManifest.xml裡的theme設定:
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
Xcode 建立 Static Library 支援 Universal Framework
Jie的懶教學,來教大家來包無敵的懶人包 Framework
1.下載解壓縮:iOS-Universal-Framework=>https://github.com/kstenerud/iOS-Universal-Framework
2.安裝Fake Framework、Real Framework,終端機進入各別目錄:輸入sh install.sh 安裝。
3.建立專案,選擇 Framework & LIbrary → Fake Static iOS Framework 樣板,
把程式拉入專案。
4.選擇TARGETS → Build Phases → Copy Headers,將.h檔拉入Public區塊裡。
5.Scheme 的 Run 設定,把 Build Configuration 改為 Release,沒改編譯會爆炸。
6.編譯完,Products 目錄裡的XXX.framework按下滑鼠右鍵,選擇 Show in Finder。
7.無embed資源的選XXX.framework,有embed資源的選 XXX.embeddedframework。
8.完工,爆肝。
1.下載解壓縮:iOS-Universal-Framework=>https://github.com/kstenerud/iOS-Universal-Framework
2.安裝Fake Framework、Real Framework,終端機進入各別目錄:輸入sh install.sh 安裝。
3.建立專案,選擇 Framework & LIbrary → Fake Static iOS Framework 樣板,
把程式拉入專案。
4.選擇TARGETS → Build Phases → Copy Headers,將.h檔拉入Public區塊裡。
5.Scheme 的 Run 設定,把 Build Configuration 改為 Release,沒改編譯會爆炸。
6.編譯完,Products 目錄裡的XXX.framework按下滑鼠右鍵,選擇 Show in Finder。
7.無embed資源的選XXX.framework,有embed資源的選 XXX.embeddedframework。
8.完工,爆肝。
2011年8月30日 星期二
2011年8月29日 星期一
2011年8月1日 星期一
AIR Mobile iPhone 離開遊戲自動關閉設定
<iPhone>
<InfoAdditions><![CDATA[
<key>UIDeviceFamily</key>
<array>
<string>1</string>
<string>2</string>
</array>
<key>UIApplicationExitsOnSuspend</key>
<true/>
]]></InfoAdditions>
<requestedDisplayResolution>high</requestedDisplayResolution>
</iPhone>
<InfoAdditions><![CDATA[
<key>UIDeviceFamily</key>
<array>
<string>1</string>
<string>2</string>
</array>
<key>UIApplicationExitsOnSuspend</key>
<true/>
]]></InfoAdditions>
<requestedDisplayResolution>high</requestedDisplayResolution>
</iPhone>
訂閱:
文章 (Atom)
