目前分類:Android (3)

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

一、Android開發環境-Eclipse

Eclipse是著名的集成開發環境(IDE),最初主要是用來Java語言的開發,隨著後來的發展,越來越多外掛程式(Plug-in)的加入,因此透過外掛程式可使Eclipse開發其他計算機語言,例如C++、Python等,亦可作為Android App的開發環境;Eclipse至今,它已佔據全世界Java開發環境市場大約65%。

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

package com.artifex.mupdfdemo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class L_Home extends Activity {

        TextView tv;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
                // TODO Auto-generated method stub
                super.onCreate(savedInstanceState);
                setContentView(R.layout.l_home);
                tv = (TextView) findViewById(R.id.textView1);
                DownloadTask dTask = new DownloadTask();
                dTask.execute(10);
        }

        @Override
        protected void onStart() {
                // TODO Auto-generated method stub
                Log.e("onStart", "onStart");
                super.onStart();
        }

        class DownloadTask extends AsyncTask<Integer, Integer, String> {
                // 後面尖括號內分別的參數是 傳入doInBackground、進度(publishProgress用到)、返回onPostExecute值類型

                @Override
                protected void onPreExecute() {
                        // 第一個執行方法
                        super.onPreExecute();
                }

                @Override
                protected String doInBackground(Integer... params) {
                        // 第二個執行方法,onPreExecute()執行完後執行
                        for (int i = 0; i <= 100; i++) {
                                try {
                                        Thread.sleep(params[0]);
                                        publishProgress(i);
                                } catch (InterruptedException e) {
                                        e.printStackTrace();
                                }
                        }
                        return "執行完畢";
                }

                @Override
                protected void onPostExecute(String result) {
                        // doInBackground返回時觸發,換句話說,就是doInBackground執行完後觸發
                        // 這裡的result就是上面doInBackground執行後的返回值,所以這裡是"執行完畢"
                        super.onPostExecute(result);
                        // Toast.makeText(L_Home.this, result, Toast.LENGTH_SHORT).show();
                        Intent intent = new Intent(L_Home.this, L_TabActivity.class);
                        startActivity(intent);
                        finish();
                }

                @Override
                protected void onProgressUpdate(Integer... progress) {
                        // 這個函數在doInBackground調用publishProgress時觸發,雖然調用時只有一個參數
                        // 但是這裡取到的是一個數組,所以要用progesss[0]來取值
                        // 第n個參數就用progress[n]來取值
                        tv.setText(progress[0] + "%");
                        super.onProgressUpdate(progress);
                }
        }
}


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

一:什麼是NDK?

NDK 提供了一系列的工具,幫助開發者快速開發C(或C++)的動態庫,並能自動將so 和java 應用一起打包成apk。這些工具對開發者的幫助是巨大的。

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