目前分類:android (6)

瀏覽方式: 標題列表 簡短摘要

幫好友 阿畢寫的
附贈了電筒的功能~
https://play.google.com/store/apps/details?id=tw.wii.app

server端:
   json輸出中文部分,先urlencode,json_encode後再urldecode
   避免產生不可閱讀之unicode編碼

app端:     

1.使用simple adapter 客製getview畫面

 2.AyncTask非同步背景呼叫json service
  使用AyncTask呼叫 才不會有NetworkOnMainThreadException

3.回傳資料:JSONArray

   轉換成 List<Map<String,Object>> 資料格式

4.硬體控制:使用CAMERA FLASH 當作手電筒

 5.需開啟權限:INTERNET,CAMERA 

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />



 

michaelfang 發表在 痞客邦 留言(0) 人氣()

1.基本安裝設定
1.Java 安裝(JAVA+JRE)

1-1 eclipse 初次使用者:  安裝adt-bundle (包含eclipse + android sdk +android platform tools)
      已是eclipse的使用者: 加裝android sdk,並於sdk中選擇安裝android platform tools(ex:4.0,2.0..)
2.執行eclipse

3.設定workspace

4.模擬器AVD Manager 新增AVD
   設定:HVGA/512MB
   Start: Scale display to resize
   Screen size(in): 5 
   Launch
   模擬器每次啟動很慢,啟動後就不要關

2.元件練習
1.使用editText,button,textview 元件
   設定fill_parent
2.setOnClickListener,輸入new 按alt+/
    會列出Event清單,選擇OnClickListener
    自動產生匿名function 

       final EditText ed1=(EditText)findViewById(R.id.editText1);;
        Button btn1=(Button)findViewById(R.id.button1);
        final TextView tv1=(TextView)findViewById(R.id.textView1);;
           //new alt+/
        btn1.setOnClickListener(new Button.OnClickListener() {
			
			public void onClick(View v) {
				// TODO Auto-generated method stub
				tv1.setText("我是"+ed1.getText().toString());
			}
		});

 






3.Application Component

四大元件:Activity, Service, Broadcast receiver, Content Provider
Activity:UI/互動/費時的放到Service/避免ANR(Android is Not Responding)
            Life Cycle要記熟
activity_lifecycle  
Service:長時間執行,無UI
             ex:撥放音樂,接收網路,壓縮
             利用binding 
Activity轉換:Intent


IntentActivity

 public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        final EditText ed =  (EditText)findViewById(R.id.editText1);
        Button btn1 = (Button)findViewById(R.id.button1);
        Button btn2 = (Button)findViewById(R.id.button2);
        
        btn1.setOnClickListener(new Button.OnClickListener() {			
			public void onClick(View v) {
				//Start the activity connect to the Result
				try{
					Intent intentResult=new Intent(Project01_IntentActivity.this,ResultAcvivity.class);
					intentResult.putExtra("username", ed.getText().toString());
					startActivity(intentResult);
					Log.e("IntentActivity","ed.getText="+ed.getText().toString());
				}catch(Exception e){
						Log.e("IntentActivity",e.toString());
				}
			
			}
		});

 



ResultActivity

protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		  setContentView(R.layout.main2);
		try{
			 TextView tv=(TextView)findViewById(R.id.textView1);
			 Intent intent=getIntent();
			 tv.setText("我是Activity2,username="+intent.getStringExtra("username"));
		}catch(Exception e){
			 Log.e("ResultAcvivity",e.toString());
		}
	}

 



1.建立2個Activity
    1.1 Package右鍵new Class
    1.2 Name:ex: ResultActivity 
    1.3 Supperclass 選擇android.app.Activity
 2.AndroidMainfest.xml
    2.1雙擊後,點選設定頁面:Application/Application Nodes/Add
    2.2選擇Activity
    2.3Attributes for Activity:輸入Name(或Browser選擇Class,ResultActivity)

    



michaelfang 發表在 痞客邦 留言(0) 人氣()

建立Log.d(TAG,"onDestroy"); 
了解每個state的前後關係
程式啟動:onCreate onStart onResume
電話進線時:onPause onStop
電話結束:onReStart onStart onResume
程式結束:onPause onStop onDestory




參考:http://developer.android.com/reference/android/app/Activity.html

michaelfang 發表在 痞客邦 留言(0) 人氣()

安裝簡化

1.java SDK

2.android SDK  

  • Eclipse + ADT plugin
  • Android SDK Tools
  • Android Platform-tools
  • The latest Android platform
  • The latest Android system image for the emulator

以上這兩個東西裝好

再設定一下系統進階設定/變數
d:\android\jdk7\bin;原始變數.....
就可以run了


michaelfang 發表在 痞客邦 留言(0) 人氣()

參考
http://appfulcrum.com/2010/08/20/android-how-to-call-rest-service-using-asynctask/

1.建立一子類別CallRestService extends AsyncTask

 

michaelfang 發表在 痞客邦 留言(0) 人氣()

picplz 提供了多種照片的特效,還可以直接把照片直接傳到facebook,flickr,twitter..等社交網站
以下均為使用HTC Legend拍攝的照片,原本手機畫質不佳,加上特效後,讓圖片變得生動了起來
完全忘了這些照片只是用手機拍攝~而focus在他的軟體效果上~

picplz_upload-Russian Toy Camera


|
picplz_upload-The 70s



picplz_upload-Little Plastic Lens


picplz_upload-High Contrast Monochrome




picplz_upload-Cross Process



picplz_upload-Instant Film

 

 最後補上原圖做個比較

原圖 by HTC legend


 

michaelfang 發表在 痞客邦 留言(0) 人氣()