2015年5月24日 星期日
[Android] Is there an example of how to use a TouchDelegate in Android to increase the size of a view's click target? (轉貼)
來源:
http://stackoverflow.com/questions/1343222/is-there-an-example-of-how-to-use-a-touchdelegate-in-android-to-increase-the-siz
http://blog.vogella.com/2012/04/15/android-using-touchdelegates/
http://stackoverflow.com/questions/2949407/can-i-increase-a-buttons-onclick-area-programmatically
2015年5月22日 星期五
2015年5月21日 星期四
[GCM] Google Cloud Messaging
Implementing Android GCM in a different package other than the main application package
http://dimitar.me/implementing-android-gcm-in-a-different-package-other-than-the-main-application-package/
Android Push Notifications using Google Cloud Messaging GCM - Android Example: http://androidexample.com/Android_Push_Notifications_using_Google_Cloud_Messaging_GCM/index.php?view=article_discription&aid=119&aaid=139
Android Push Notifications using Google Cloud Messaging (GCM), PHP and MySQL (ipcam use this sample)
http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
Android Google Cloud Messaging (GCM) 入門筆記
http://hsuchihche.pixnet.net/blog/post/316287368-android-google-cloud-messaging-(gcm)-%E5%85%A5%E9%96%80%E7%AD%86%E8%A8%98
https://fundroiding.wordpress.com/2012/06/29/google-cloud-messaging-for-android-gcm-simple-tutorial/
http://www.androidhub4you.com/2013/04/google-cloud-messaging-example-in.html
http://magiclen.org/android-push-notification/
Android Push Notifications using Google Cloud Messaging GCM - Android Example: http://androidexample.com/Android_Push_Notifications_using_Google_Cloud_Messaging_GCM/index.php?view=article_discription&aid=119&aaid=139
Android Push Notifications using Google Cloud Messaging (GCM), PHP and MySQL (ipcam use this sample)
http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
Android Google Cloud Messaging (GCM) 入門筆記
http://hsuchihche.pixnet.net/blog/post/316287368-android-google-cloud-messaging-(gcm)-%E5%85%A5%E9%96%80%E7%AD%86%E8%A8%98
https://fundroiding.wordpress.com/2012/06/29/google-cloud-messaging-for-android-gcm-simple-tutorial/
http://www.androidhub4you.com/2013/04/google-cloud-messaging-example-in.html
http://magiclen.org/android-push-notification/
2015年5月20日 星期三
[Java] float , double and which situation will loss of the precision
數值與字串型態
在基本型態中,依需要的資料精確度不同,浮點數可以使用
來源:http://www.codedata.com.tw/java/java-tutorial-the-2nd-class-1-numeric-types-and-string/
資料型別http://programming.im.ncnu.edu.tw/J_index.html
float
(四位元組) 與double
(八位元組)兩個型態。在程式中寫下像是 0.3 這樣的浮點數實字,會使用double
型態,因此 …來源:http://www.codedata.com.tw/java/java-tutorial-the-2nd-class-1-numeric-types-and-string/
資料型別http://programming.im.ncnu.edu.tw/J_index.html
2015年5月19日 星期二
[Android] Session Initiation Protocol
PCM G711
http://stackoverflow.com/questions/23273866/issue-encoding-and-decoding-an-audio-recording-to-g711-pcmu-ulaw-format
http://blog.liangkuo.org/2007/01/java.html
http://iainstnote.blogspot.tw/2012/08/androidudp-socketp2p_18.html
How to integrate SIP into Android?
http://stackoverflow.com/questions/23273866/issue-encoding-and-decoding-an-audio-recording-to-g711-pcmu-ulaw-format
http://blog.liangkuo.org/2007/01/java.html
http://iainstnote.blogspot.tw/2012/08/androidudp-socketp2p_18.html
How to integrate SIP into Android?
http://stackoverflow.com/questions/12635382/how-to-integrate-sip-into-android
https://code.google.com/p/imsdroid/
http://www.live555.com/liveMedia/
SIP sample
http://www.shuyangyang.com.cn/jishuliangongfang/qitajishu/2013-08-14/106.html
http://doc.gotomao.com/doc/android/api/resources/samples/SipDemo/index.html
https://android.googlesource.com/platform/development/+/master/samples/SipDemo/
https://code.google.com/p/sip2peer/downloads/detail?name=Android-Sip2Peer-1.0.zip&can=2&q=
http://blog.csdn.net/c_m_deng/article/details/8850494
http://www.telestax.com/jain-sip-stack-for-android/
Session Initiation Protocol
http://developer.android.com/guide/topics/connectivity/sip.html
--------------------------
https://code.google.com/p/imsdroid/
http://www.live555.com/liveMedia/
SIP sample
http://www.shuyangyang.com.cn/jishuliangongfang/qitajishu/2013-08-14/106.html
http://doc.gotomao.com/doc/android/api/resources/samples/SipDemo/index.html
https://android.googlesource.com/platform/development/+/master/samples/SipDemo/
https://code.google.com/p/sip2peer/downloads/detail?name=Android-Sip2Peer-1.0.zip&can=2&q=
http://blog.csdn.net/c_m_deng/article/details/8850494
http://www.telestax.com/jain-sip-stack-for-android/
Session Initiation Protocol
http://developer.android.com/guide/topics/connectivity/sip.html
--------------------------
提供你有關two way
audio 的資訊。
Our
reference code came from http://www.live555.com/liveMedia/public/
For
SIP client and protocol negotiation, please refer “liveMedia\SIPClient.cpp” and
“testProgs\playSIP.cpp”.
For
sending audio, please refer
“testProgs\testWAVAudioStreamer.cpp”.
And
our server receives u-law audio.
目前測試連線已經打通,但是機器上的
DAC 設定還有點問題,所以聲音解壓縮之後還是無法發出聲音。
BR,
Raymond
2015年5月18日 星期一
[Android] List files on Google Drive
query and sort
https://developers.google.com/drive/android/queries
https://github.com/googledrive/android-demos
http://runnable.com/UTlPMF-f2W1TAAAj/list-files-on-google-drive
http://stackoverflow.com/questions/tagged/google-api-java-client
http://anything0951.blogspot.tw/2013/07/eclipse-java-google-drive-api.html
https://developers.google.com/drive/android/queries
https://github.com/googledrive/android-demos
http://runnable.com/UTlPMF-f2W1TAAAj/list-files-on-google-drive
http://stackoverflow.com/questions/tagged/google-api-java-client
http://anything0951.blogspot.tw/2013/07/eclipse-java-google-drive-api.html
2015年5月17日 星期日
2015年5月11日 星期一
[Google drive] file share and download (轉貼)
來源:http://gsyan888.blogspot.tw/2013/02/google-drive-download-link.html
我們只要把 fileId 套到底下的格式就可以得到它的下載連結:
- https://drive.google.com/uc?export=download&id=fileId
上面的例子套上 fileId 變成:
另外,把 download 改為 view,套入底下的格式應該也可以:
- https://drive.google.com/uc?export=view&id=fileId
也就是變成:
http://free.com.tw/howto-sharing-files-in-google-drive-dropbox/http://www.wfublog.com/2013/10/google-drive-file-link.html
http://xyz.cinc.biz/2014/01/google-drive-direct-download-bookmarklet.html
http://gsyan888.blogspot.tw/2013/02/google-drive-download-link.html
[Android] startActivityForResult
CameraList.java
About.java
@Override protected void onCreate(Bundle savedInstanceState) { ib_about.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //check the internet is avaiable or not if(!new NetworkAccess().isOnline(cm)){ new NetworkAccess().dialog_openInternet(builder); }else{ Intent intent = new Intent(CameraList.this, About.class); intent.putExtras(bundle); startActivityForResult(intent, 1); } } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 1) { if (resultCode == RESULT_OK) { String result = data.getStringExtra("data"); if (result.equals("done_logout")) { // VLCApplication.setIsStopThumbloading(true); CameraList.this.finish(); }else{ //update userinfo from ModifyUser if(VLCApplication.getIsUpdateUserInfo()){ if (getIntent().getExtras() != null) { bundle = getIntent().getExtras(); // bundle.putString("email", VLCApplication.getModifyUser_email()); bundle.putString("u_name", VLCApplication.getModifyUser_name()); bundle.putString("PWD", VLCApplication.getModifyUser_pwd()); VLCApplication.setIsUpdateUserInfo(false); } } } } } }
About.java
@Override protected void onCreate(Bundle savedInstanceState) { ib_goback.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // EventSetting.this.finish(); isLogout="NotYet"; About.this.finish(); } }); rl_logout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { isLogout="done_logout"; About.this.finish(); } }); } @Override public void finish() { Intent it = new Intent(); it.putExtra("data", isLogout); setResult(RESULT_OK, it); super.finish(); }
[Android] File sort, delete, folder create
Sort:
Delete:
Folder create:
File[] files = XMLDirectory.listFiles(filter_xml_files); Arrays.sort(files);
//Arrays.sort(files, Collections.reverseOrder()); //resort for(File _xml_file : files) { ... }reference: http://stackoverflow.com/questions/7199911/how-to-file-listfiles-in-alphabetical-order
Delete:
File file = new File(selectedFilePath); boolean deleted = file.delete();reference: http://stackoverflow.com/questions/1248292/how-to-delete-a-file-from-sd-card
Folder create:
java.io.File file = new java.io.File(save_path); /* if the folder is not exist, create it */ if (!file.exists()) file.mkdirs();
2015年5月10日 星期日
[Android] Timer
public class DemoTimerTask { public static void main(String[] args) { java.util.Timer timer = new java.util.Timer(); java.util.TimerTask task = new java.util.TimerTask(){ @Override public void run() { System.out.println("需要定时执行的任务..."); } }; java.util.Date time = new java.util.Date(); long delay = 2000; long period = 5000; //启动定时任务,立即执行壹次退出 timer.schedule(task, time); //启动定时任务,在 time 指定的时间执行壹次,然后每隔两秒执行壹次 // timer.schedule(task, time, delay); //启动定时任务,从现在起过两秒执行壹次,然后退出 // timer.schedule(task, delay); //启动定时任务,从现在起过两秒以后,每隔五秒执行壹次 // timer.schedule(task, delay, period); } }
reference:http://www.oschina.net/question/136226_126079
[Android] file delete
//remove past thumbnail String del_path = Environment.getExternalStorageDirectory() + "/Download/IPCam/"+camIDArr[camIndex]+"/thumbnail/"; File dir = new File(del_path); Log.e("Environment.getExternalStorageDirectory()+del_path",del_path); if (dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { Log.e("^^^^^^^^^=====> children["+i+"]",children[i]); File imgFile = new File(del_path+children[i]); if(imgFile.exists()){ new File(dir, children[i]).delete(); } } }
[Android] check files is exist or not and then remove files
//remove past thumbnail String del_path = Environment.getExternalStorageDirectory() + "/Download/IPCam/"+camIDArr[camIndex]+"/thumbnail/"; File dir = new File(del_path); Log.e("Environment.getExternalStorageDirectory()+del_path",del_path); if (dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { Log.e("^^^^^^^^^=====> children["+i+"]",children[i]); File imgFile = new File(del_path+children[i]); if(imgFile.exists()){ new File(dir, children[i]).delete(); } } }
[Android] two ways to get photo in the List View
int tmp_index = 0; final List < Map < String, Object >> data = new ArrayList< Map< String, Object >>(); for (int i = 0; i < camNameArr.length; i++) { Map< String, Object> item = new HashMap< String, Object>(); item.put("name", camNameArr[i]); //----get photo from project Log.e("camIDArr[i] " +i,""+camIDArr[i]); Log.e("*tmp_index",""+tmp_index); item.put("image", mPics[i]); // // ----get photo from sd card // String photoName = "main" + (i + 1) + ".jpg"; // // new DownloadImagesToSdCard("http://spaceflightnow.com/news/n0211/04soho/sun.jpg",photoName, savePhotoPath); // item.put("image", savePhotoPath + photoName); data.add(item); }
2015年5月9日 星期六
[Android] remove files from the specific folder
//remove past thumbnail String del_path = Environment.getExternalStorageDirectory() + "/Download/IPCam/"+camIDArr[camIndex]+"/thumbnail/"; File dir = new File(del_path); Log.e("Environment.getExternalStorageDirectory()+del_path",del_path); if (dir.isDirectory()) { String[] children = dir.list(); for (int i = 0; i < children.length; i++) { Log.e("^^^^^^^^^=====> children["+i+"]",children[i]); //children[i] => file name , for example snapshot_20150509140728.jpg new File(dir, children[i]).delete(); } }
2015年5月8日 星期五
[Android] avoid two different thread call a function in the same time
when two thread call the function of changeThumbnail in the part2, we can make a code like part1 into this function in order to avoid crash.
part1:
part1:
isReadyChgPhoto=true; while(isReadyChgPhoto!=true){ Log.e("please wait "+i +"sec","wait===================="); i++; SystemClock.sleep(1000); } isReadyChgPhoto=false;part2:
isReadyChgPhoto=true; private void changeThumbnail(final int index, final int localport){ new Thread(new Runnable() { public void run() { int i=0; while(isReadyChgPhoto!=true){ Log.e("please wait "+i +"sec","wait===================="); i++; SystemClock.sleep(1000); } isReadyChgPhoto=false; SystemClock.sleep(1000); VLCApplication.setCurrUID(camIDArr[index]); //for download thumbnail use String cmd_snapshot="http://127.0.0.1:"+localport+"/cgi-bin/cgi-cmd.cgi?command=snapshot"; Log.e("%% get camera thumnail",cmd_snapshot+" uid: "+camIDArr[index]); new CGICommandForThumbnail(cmd_snapshot,"snapshot", localport, index).start(); SystemClock.sleep(1000); isReadyChgPhoto=true; } }).start(); }
[Android] set image from sd card
File imgFile = new File(thumbnailPath); if(imgFile.exists()){ Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath()); iv_liveView=(ImageView) listView.getChildAt(camIndex).findViewById(R.id.iv_liveView); iv_liveView.setImageBitmap(myBitmap); }
==================
//----get photo from project Log.e("camIDArr[i] " +i,""+camIDArr[i]); Log.e("*tmp_index",""+tmp_index); item.put("image", mPics[i]); // ----get photo from sd cardString photoName = "main" + (i + 1) + ".jpg"; // new DownloadImagesToSdCard("http://spaceflightnow.com/news/n0211/04soho/sun.jpg",photoName, // savePhotoPath);item.put("image", savePhotoPath + photoName);
2015年5月7日 星期四
[Teaching MAP] Android
HTTP POST and GET (without using thread, the problem of ANR will be generated.)
http://blog.tonycube.com/2011/11/androidget-post.html
[JSON] json object vs array
JSON Object:
JSON Array:
JSON Value:
JSON String:
reference:
http://blog.kkbruce.net/2011/01/json.html#.VUwO9fmqpBc
====================================
- 以"{"開始,以"}"結尾
- 每個名稱後跟著一個":"
- 每對"名稱:值"之間用","分隔
1 | { // 以"{"開始 |
2 | 'name' : 'Bruce' , // 每個名稱後跟著一個":" |
3 | 'age' : 18, // 每對"名稱:值"之間用","分隔 |
4 | 'sex' : 'male' |
5 | } // 以"}"結尾 |
JSON Array:
- 以"["開始,以"]"結尾
- 值之間使用","
01 | { |
02 | // familys為一維陣列,陣列裡包含兩筆物件資料 |
03 | 'familys' = [ // 以"["開始 |
04 | { 'name' : 'Bruce' , |
05 | 'age' : 18, |
06 | 'sex' : 'male' }, // 值之間使用"," |
07 | { 'name' : 'Sherry' , |
08 | 'age' : 16, |
09 | 'sex' : 'famale' } |
10 | ] // 以"]"結尾 |
11 | } |
JSON Value:
- 值本身可以是String、Number、true、false、null、Object、Array;
JSON String:
- 由雙引號包圍的任意Unicode字元集合。可以使用"反斜線(\)"來轉義。
1 | { |
2 | "details" : "這是JSON的值. \n 此格式比XML合適Ajax交換資料使用." |
3 | } |
reference:
http://blog.kkbruce.net/2011/01/json.html#.VUwO9fmqpBc
====================================
單行及多行json格式, 字串轉json的分別。
//multiple line
temp="[{'px_emp_id':'1','px_emp_name':'jean','px_emp_tel':'337','px_emp_url':''}]";
JSONArray result_arr = new JSONArray(temp);
JSONObject result_obj = result_arr.getJSONObject(0); //Convert String to JSON Object, get first line
// //only one line
// temp="{'px_emp_id':'1','px_emp_name':'jean','px_emp_tel':'337','px_emp_url':''}";
// JSONObject result_obj = new JSONObject(temp); //Convert String to JSON Object
mTextView1.setText(result_obj.getString("px_emp_name"));
========================================
temp="[{'px_emp_id':'1','px_emp_name':'jean','px_emp_tel':'337','px_emp_url':''}]";
JSONArray result_arr = new JSONArray(temp);
JSONObject result_obj = result_arr.getJSONObject(0); //Convert String to JSON Object, get first line
// //only one line
// temp="{'px_emp_id':'1','px_emp_name':'jean','px_emp_tel':'337','px_emp_url':''}";
// JSONObject result_obj = new JSONObject(temp); //Convert String to JSON Object
mTextView1.setText(result_obj.getString("px_emp_name"));
========================================
// try {// JSONObject jo;// jo = new JSONObject(myCamera);// Collection<JSONObject> items = new ArrayList<JSONObject>();// //// JSONObject item1 = new JSONObject();//// item1.put("CameraName", "New Camera");//// item1.put("CameraID", "PXCAM1_");//// items.add(item1);// //// jo.put("aoColumnDefs", new JSONArray(items));//// Log.e("items",items.toString());// myCamera=jo.toString();//// } catch (JSONException e) {// // TODO Auto-generated catch block// e.printStackTrace();// }// Log.e("u_id"+u_id,"***");// Log.e("u_name"+u_name,"***");// Log.e("myCamera_num",""+myCamera_num);// Log.e("myCamera",""+myCamera);// Log.e("followingCamera_num",""+followingCamera_num);// Log.e("followingCamera",""+followingCamera); Log.e("======================","======================"); // JSONArray result_arr = null; // try { // result_arr = new JSONArray(myCamera); // Log.e("getJSONObject(0).getString(CameraName)",""+result_arr.getJSONObject(0).getString("CameraName").toString()); // Log.e("getJSONObject(0).getString(CameraName)",""+result_arr.getJSONObject(0).getString("CameraID").toString()); // Log.e("getJSONObject(1).getString(CameraName)",""+result_arr.getJSONObject(1).getString("CameraName").toString()); // Log.e("getJSONObject(1).getString(CameraName)",""+result_arr.getJSONObject(1).getString("CameraID").toString()); // } catch (JSONException e1) { // // TODO Auto-generated catch block // e1.printStackTrace(); // }
訂閱:
文章 (Atom)