2015年4月30日 星期四
[Android] change photo regularly
change photo in each two seconds.
http://stackoverflow.com/questions/1520887/how-to-pause-sleep-thread-or-process-in-android
2015年4月29日 星期三
[Android] check APP exist or not
以VLC APP為例
private View.OnClickListener marketListener=new View.OnClickListener() {
@Override
public void onClick(View v) {
if(isPackageExisted("org.videolan.vlc")){
Toast.makeText(getApplicationContext(), "the APP is exist.", Toast.LENGTH_SHORT).show();
}else{
// 尋找某個應用程式
Uri uri = Uri.parse("market://search?q=pname:org.videolan.vlc");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
}
}
};
public boolean isPackageExisted(String targetPackage){
PackageManager pm=getPackageManager();
try {
PackageInfo info=pm.getPackageInfo(targetPackage,PackageManager.GET_META_DATA);
} catch (NameNotFoundException e) {
return false;
}
return true;
}
2015年4月22日 星期三
2015年4月21日 星期二
[Android] Android The method startActivity(Intent) is undefined
Android The method startActivity(Intent) is undefined for the type new View.OnClickListener(){}
You can pass the object activity class to the adapter, from which you are calling the adapter. Then use that object to call startActivity.
reference:
http://stackoverflow.com/questions/13983129/android-the-method-startactivityintent-is-undefined-for-the-type-new-view-oncl
http://stackoverflow.com/questions/17505969/how-to-fix-the-method-startactivityintent-is-undefined-for-the-type-new-view-o
2015年4月20日 星期一
[Android] android audio streaming
Android RTP Sample (Receiving via VLC player)
http://androidsourcecode.blogspot.tw/2013/10/android-rtp-sample-receiving-via-vlc.html
Android源码分析:VoIP
http://androidsourcecode.blogspot.tw/2013/10/android-rtp-sample-receiving-via-vlc.html
Android源码分析:VoIP
2015年4月19日 星期日
[Android] Add View
the sample show the way how to create view or main activity programmatically.
MainActivity.java
AndroidManifest.xml
MainActivity.java
package com.example.addview;
import android.app.Activity;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout layoutMain = new LinearLayout(this);
layoutMain.setOrientation(LinearLayout.VERTICAL); //設定layout為子物件排列方式為垂直
setContentView(layoutMain); //將create的layoutMain(LinearLayout)做為主要的activity
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); //設定layout為顯示方式垂直
//將子頁login_title及login加入layoutMain
LayoutInflater inflate = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
RelativeLayout layoutTitle = (RelativeLayout) inflate.inflate(
R.layout.login_title, null);
RelativeLayout layoutBody = (RelativeLayout) inflate.inflate(
R.layout.login, null);
//設定login_title及login加入layout的屬性
RelativeLayout.LayoutParams relParam = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
layoutMain.addView(layoutTitle, relParam);
layoutMain.addView(layoutBody, relParam);
// 動態產生TextView
TextView tv = new TextView(this);
tv.setText("Hello World");
// 將 TextView 加入到login.xml中 (在login.xml中的RelativeLayout元件,需命名id名稱(rl_body)
RelativeLayout rl_body= (RelativeLayout)findViewById(R.id.rl_body);
rl_body.addView(tv);
}
}
login_title.xmllogin.xml
AndroidManifest.xml
2015年4月16日 星期四
[JSON] JSON edit in java
reference:
http://stackoverflow.com/questions/11143363/add-data-to-jsonobject
In order to have this result:
that holds the same data as:
you could use this code:
JSONObject jo = new JSONObject(); Collection<JSONObject> items = new ArrayList<JSONObject>(); JSONObject item1 = new JSONObject(); item1.put("aDataSort", new JSONArray(0, 1)); item1.put("aTargets", new JSONArray(0)); items.add(item1); JSONObject item2 = new JSONObject(); item2.put("aDataSort", new JSONArray(1, 0)); item2.put("aTargets", new JSONArray(1)); items.add(item2); JSONObject item3 = new JSONObject(); item3.put("aDataSort", new JSONArray(2, 3, 4)); item3.put("aTargets", new JSONArray(2)); items.add(item3); jo.put("aoColumnDefs", new JSONArray(items)); System.out.println(jo.toString()); |
2015年4月15日 星期三
[Knowledge] programming learning
Android Hive
http://www.androidhive.info/
tutorials point
http://www.tutorialspoint.com//android/index.htm
如何透過Android Studio產生向量圖http://givemepass.blogspot.tw/2015/12/android-studio.html
GiveMePasS's Android惡補筆記http://givemepass.blogspot.tw/
Free icon
Icons8
http://icons8.com/
Android Asset Studio
http://romannurik.github.io/AndroidAssetStudio/index.html
Android develop
http://developer.android.com/design/downloads/index.html
Android develop blog
http://android-developers.blogspot.tw/2013/07/making-beautiful-android-app-icons.html
[Android] share photo or video with fb, gmail, messages..
String path=Environment.getExternalStorageDirectory().toString()+"/Download/IPCam/UID/photo/event/test0._1.png";
//String path=Environment.getExternalStorageDirectory().toString()+"/Download/IPCam/UID/video/event/test1.mp4";
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, "test");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(path)));
intent.setType("image/jpeg");
startActivity( Intent.createChooser(intent,"Send with"));
reference: https://developers.facebook.com/bugs/363863587019268
=======================================
Customize Android Intent.ACTION_SEND
http://stackoverflow.com/questions/20015410/customize-android-intent-action-send
Sending Simple Data to Other Apps (Send Multiple Pieces of Content)
[Android] Android Fullscreen Image Slider with Swipe and Pinch Zoom Gestures (轉貼)
來源:
http://www.androidhive.info/2013/09/android-fullscreen-image-slider-with-swipe-and-pinch-zoom-gestures/
remember to add permission as below,
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
2015年4月14日 星期二
[Android] Open gallery from folder (call other APP)
ib_gallery = (ImageButton) findViewById(R.id.ib_gallery);
ib_gallery.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.e("Environment.getExternalStorageDirectory()",""+Environment.getExternalStorageDirectory().getPath());
Uri selectedUri = Uri.parse(Environment.getExternalStorageDirectory().getPath() +
"/Download/IPCam/"+VLCApplication.getCurrUID()+"/snapshot/liveview/");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(selectedUri, "resource/folder");
startActivity(intent);
}
});
String path=Environment.getExternalStorageDirectory().toString()+"/Download/IPCam/main8.jpg";
Log.e("path",path);
Intent i=new Intent();
i.setAction(Intent.ACTION_VIEW);
i.setDataAndType(Uri.fromFile(new File(path)), "image/*");
startActivity(i);
2015年4月8日 星期三
Android: How to open a specific folder via Intent and show its content in a file browser? (轉貼)
來源:http://stackoverflow.com/questions/17165972/android-how-to-open-a-specific-folder-via-intent-and-show-its-content-in-a-file
public void openFolder()
{
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()
+ "/myFolder/");
intent.setDataAndType(uri, "text/csv");
startActivity(Intent.createChooser(intent, "Open folder"));
}
Uri selectedUri = Uri.parse(Environment.getExternalStorageDirectory() + "/myFolder/"); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(selectedUri, "resource/folder"); startActivity(intent);
2015年4月3日 星期五
[Virtual Box] Virtual Box更改儲存OS路衡
reference: http://mitblog.pixnet.net/blog/post/40456132-virtualbox-%E8%AE%8A%E6%9B%B4-vbox-%E8%B7%AF%E5%BE%91
系統預設儲存於 defaultMachineFolder,更改其字串即可。
<SystemProperties defaultMachineFolder="C:\Users\px1255\VirtualBox VMs" defaultHardDiskFormat="VDI" VRDEAuthLibrary="VBoxAuth" webServiceAuthLibrary="VBoxAuth" LogHistoryCount="3" exclusiveHwVirt="false"/>
系統預設儲存於 defaultMachineFolder,更改其字串即可。
<SystemProperties defaultMachineFolder="C:\Users\px1255\VirtualBox VMs" defaultHardDiskFormat="VDI" VRDEAuthLibrary="VBoxAuth" webServiceAuthLibrary="VBoxAuth" LogHistoryCount="3" exclusiveHwVirt="false"/>
test
http://www.bkjia.com/Androidjc/949066.html
http://www.cnblogs.com/mythou/p/3162595.html
http://naveen-shrivastva.blogspot.tw/2011/12/compiling-vlc-from-source-for-apk.html
http://www.cnblogs.com/dwayne/archive/2012/12/21/vlc_android.html
=================================================
http://tradedev.blogspot.tw/2013/10/vlc-android.html
http://blog.csdn.net/mlj1668956679/article/details/9530125
http://blog.chinaunix.net/uid-25885064-id-3355979.html
http://blog.csdn.net/deng0zhaotai/article/details/37901557
http://blog.csdn.net/deng0zhaotai/article/details/38032645
===========================================
https://wiki.videolan.org/AndroidCompile/
http://www.tidroid.com/article_110.html
http://www.cnblogs.com/mythou/p/3162595.html
============================
new:
http://blog.csdn.net/vertx/article/details/8559385
http://blog.csdn.net/shulianghan/article/details/42707293
import three libs
error: Error: No resource found that matches the given name: attr 'actionBarStyle'.
http://www.cnblogs.com/mythou/p/3162595.html
http://naveen-shrivastva.blogspot.tw/2011/12/compiling-vlc-from-source-for-apk.html
http://www.cnblogs.com/dwayne/archive/2012/12/21/vlc_android.html
=================================================
http://tradedev.blogspot.tw/2013/10/vlc-android.html
http://blog.csdn.net/mlj1668956679/article/details/9530125
http://blog.chinaunix.net/uid-25885064-id-3355979.html
http://blog.csdn.net/deng0zhaotai/article/details/37901557
http://blog.csdn.net/deng0zhaotai/article/details/38032645
===========================================
https://wiki.videolan.org/AndroidCompile/
http://www.tidroid.com/article_110.html
http://www.cnblogs.com/mythou/p/3162595.html
============================
new:
http://blog.csdn.net/vertx/article/details/8559385
http://blog.csdn.net/shulianghan/article/details/42707293
import three libs
error: Error: No resource found that matches the given name: attr 'actionBarStyle'.
2015年4月1日 星期三
[Android] Android checkbox style (轉貼)
reference : http://stackoverflow.com/questions/10135499/android-checkbox-style
My application style is set to Theme.Holo which is dark and I would like the check boxes on my list view to be of style Theme.Holo.Light. I am not trying to create a custom style. The code below doesn't seem to work, nothing happens at all.
Android中自定义checkbox样式
訂閱:
意見 (Atom)