HTML/JavaScript小工具

HTML/JavaScript小工具

2012年12月18日 星期二

IPC名詞解釋(簡單版)


轉貼文章用來記綠

Remote Procedure Call

謂的procedure call或稱為function call,是一種廣泛運用於programming的流程控制。運作
方式是將控制權從一個process的某部份轉移到另一個process,進行某些運算之後,再把
控制權歸還給呼叫這個procedure的呼叫者。在進行procedure call時,caller會傳送一些參數
給被呼叫者;而被呼叫者也會將一個或多個傳回值傳給呼叫者。

一般而言,若呼叫者與被呼叫者是在同一個系統內,我們稱為local procedure call
若呼叫者與被呼叫者處於不同的系統,也就是說,呼叫者在local端透過網路來呼叫remote端
的procedure,我們稱為remote procedure call(簡稱為RPC),中文翻譯為遠端程序呼叫



inter-Process Communication IPC (Process 之間溝通)
在Android中是使用Binder來通訊!

Android Thread的限制!


  1. Do not block the UI thread 
  2. Do not access the Android UI toolkit from outside the UI thread

由第二點得知只能在UI Thread控制UI所以~~~Android提供了以下簡單方法:
這些方法可以讓你在另外一個執行緒控制UI

但是程式中過多這樣的寫法是不好的,於是發展了一個AsyncTask ,可將UI與背景想做的事分開,如此程式維護上比較清晰


要使用AsyncTask  必須Extends AsyncTask 做法如下:已下轉貼Android API低阿~


public void onClick(View v) {
    //你要執行時呼叫execute
    new DownloadImageTask().execute("http://example.com/image.png");
}

private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
    /** The system calls this to perform work in a worker thread and
      * delivers it the parameters given to AsyncTask.execute() */
    protected Bitmap doInBackground(String... urls) {
        //這裡做你想在背景做的事,如由網錄下在圖檔等...
return loadImageFromNetwork(urls[0]);
    }
    
    /** The system calls this to perform work in the UI thread and delivers
      * the result from doInBackground() */
    protected void onPostExecute(Bitmap result) {
//這裡做在UI裡顯示什麼東西!如將網路抓來的圖片顯示在ImageView中
        mImageView.setImageBitmap(result);
    }
}
其他:


微蝦咪要用Service!!

在Android內
Service跟Threds用法看起來很像喔!!~~
但他們是2個不同的東東!!

1 Service有自己的生命週期
2 使用Service時,會進入Service process ,這樣當Android自動刪除process會將他列入權重
3 Service可以使用ADIL!

以上...這只是筆記!!~~提供參考~~GOGO~~

Android Process 刪除順序


  1. Foreground process
    A process that is required for what the user is currently doing. A process is considered to be in the foreground if any of the following conditions are true:
    Generally, only a few foreground processes exist at any given time. They are killed only as a last resort—if memory is so low that they cannot all continue to run. Generally, at that point, the device has reached a memory paging state, so killing some foreground processes is required to keep the user interface responsive.
  2. Visible process
    A process that doesn't have any foreground components, but still can affect what the user sees on screen. A process is considered to be visible if either of the following conditions are true:
    • It hosts an Activity that is not in the foreground, but is still visible to the user (its onPause() method has been called). This might occur, for example, if the foreground activity started a dialog, which allows the previous activity to be seen behind it.
    • It hosts a Service that's bound to a visible (or foreground) activity.
    A visible process is considered extremely important and will not be killed unless doing so is required to keep all foreground processes running.
  3. Service process
    A process that is running a service that has been started with the startService() method and does not fall into either of the two higher categories. Although service processes are not directly tied to anything the user sees, they are generally doing things that the user cares about (such as playing music in the background or downloading data on the network), so the system keeps them running unless there's not enough memory to retain them along with all foreground and visible processes.
  4. Background process
    A process holding an activity that's not currently visible to the user (the activity's onStop() method has been called). These processes have no direct impact on the user experience, and the system can kill them at any time to reclaim memory for a foreground, visible, or service process. Usually there are many background processes running, so they are kept in an LRU (least recently used) list to ensure that the process with the activity that was most recently seen by the user is the last to be killed. If an activity implements its lifecycle methods correctly, and saves its current state, killing its process will not have a visible effect on the user experience, because when the user navigates back to the activity, the activity restores all of its visible state. See the Activities document for information about saving and restoring state.
  5. Empty process
    A process that doesn't hold any active application components. The only reason to keep this kind of process alive is for caching purposes, to improve startup time the next time a component needs to run in it. The system often kills these processes in order to balance overall system resources between process caches and the underlying kernel caches.

2012年12月11日 星期二

慢慢讀Android API系列之 --Context-1

慢慢讀Android API系列之 --Context-1

挑選了一些我覺得比較重要的方法或一些參數


ACCESSIBILITY_SERVICE-- 輔助服務(類似無障礙App)
AUDIO_SERVICE--跟聲音與震動有關的服務
CLIPBOARD_SERVICE --可取得剪貼簿管理
DEVICE_POLICY_SERVICE 可管理和操作设备的API
DOWNLOAD_SERVICE--可取得下載服務

DROPBOX_SERVICE --DropBoxManager 是 Android 在 Froyo(API level 8) 引入的用来持续化存储系统数据的机制, 主要用于记录 Android 运行过程中, 内核, 系统进程, 用户进程等出现严重问题时的 log, 可以认为这是一个可持续存储的系统级别的 logcat.我们可以通过用参数 DROPBOX_SERVICE 调用 getSystemService(String) 来获得这个服务, 并查询出所有存储在 DropBoxManager 里的系统错误记录.
INPUT_METHOD_SERVICE--可取得管理軟體鍵盤的服務
KEYGUARD_SERVICE--鍵盤鎖管理
LOCATION_SERVICE--跟GPS比較有關係低
MEDIA_ROUTER_SERVICE-->JELLY才有低

MODE_APPEND--> openFileOutput會用到的參數
NOTIFICATION_SERVICE-->傳遞訊息的服務
POWER_SERVICE-->取得管理電源的服務
STORAGE_SERVICE-->可以管理OOB文檔(有機會研究一下)
TELEPHONY_SERVICE-->電話管理服務(有誰打來啦等等資訊)
UI_MODE_SERVICE-->Android设备的夜间模式和行车模式


USB_SERVICE-->3.1之後才可用的方法



以上這些SERVICE之後會慢慢低介紹一下!!!







下面這些方法的用法之後也會介紹
 createPackageContext
getSystemService(String) 



2012年11月29日 星期四

檢查隱含intent是否可執行!


當中幾個比較關鍵的的方法如下:

PackageManager packageManager = getPackageManager(); 取得管理器
List<ResolveInfo> activities = packageManager.queryIntentActivities(mapIntent, 0);查詢Intent是否有相對應的程式
boolean isIntentSafe = activities.size() > 0;如果activities (有相對的應用程式)大於零isIntentSafe 就是true

// Build the intent
Uri location = Uri.parse("geo:0,0?q=1600+Amphitheatre+Parkway,+Mountain+View,+California");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, location);

// Verify it resolves
PackageManager packageManager = getPackageManager();
List<ResolveInfo> activities = packageManager.queryIntentActivities(mapIntent, 0);
boolean isIntentSafe = activities.size() > 0;
  
// Start an activity if it's safe
if (isIntentSafe) {
    startActivity(mapIntent);
}

2012年11月28日 星期三

Server程序內啟動Activity程序(記錄用)


Android的程式除了可見的Activity以外,其實還有在背景服務的Service
只是Service想要用Intent去啟動Activity可能會遇到錯誤,因為沒有加上Flag
!!很重要,Server要啟動Activity一定要加上Intent.FLAG_ACTIVITY_NEW_TASK的Flag

以下範例就可以在Server程序內啟動Activity程序了
引言:


public class backgroundServer extends Service{
...

public void startMainActivity(){
Intent i = new Intent();
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setClass(backgroundServer.this, mainActivity.class);
startActivity(i);
}
...
}

2012年11月27日 星期二

onStop與onPause(記錄用)


onPause和onStop的区别

onPause 用于由一个Activity转到另一个Activity、设备进入休眠状态(屏幕锁住了)、或者有dialog弹出时
onStop 用于不可见的Activity(有对话框弹出时,这时底下的activity仍然可见,所以此时onStop不会被调用)
从下面的日志日志可以看出区别:
1.从FirstActivity跳到SecondActivity时
FirstAcvity ---> onCreate
FirstAcvity --->onStart
FirstAcvity --->onResume
FirstAcvity --->onPause
SecondActivity--->onCreate
SecondActivity--->onStart
SecondActivity--->onResume
FirstAcvity --->onStop
现在给AndroidMainfest.xml中的SeconedActivity属性加入android:theme="@android:style/Theme.Dialog",则SeconedActivity将以对话框形式出现,不会对FirstAcvity形成遮盖.
  这时的状态输出为:
FirstAcvity ---> onCreate
FirstAcvity --->onStart
FirstAcvity --->onResume
FirstAcvity --->onPause
SecondActivity--->onCreate
SecondActivity--->onStart
SecondActivity--->onResume
这时FirstAcvity比完全遮盖时少调用了onStop方法.

2012年11月3日 星期六

MediaPlayer SDK 翻譯一下

MediaPlayer类可用于控制音频/视频文件或流的播放。关于如何使用这个类的方法还可以阅读VideoView类的文档。


1.状态图
对播放音频/视频文件和流的控制是通过一个状态机来管理的。下图显示一个MediaPlayer对象被支持的播放控制操作驱动的生命周期和状态。椭圆代表MediaPlayer对象可能驻留的状态。弧线表示驱动MediaPlayer在各个状态之间迁移的播放控制操作。这里有两种类型的弧线。由一个箭头开始的弧代表同步的方法调用,而以双箭头开头的代表的弧线代表异步方法调用

 



通过这张图,我们可以知道一个MediaPlayer对象有以下的状态:

1)当一个MediaPlayer对象被刚刚用new操作符创建或是调用了reset()方法后,它就处于Idle状态。当调用了release()方法后,它就处于End状态。这两种状态之间是MediaPlayer对象的生命周期。

1.1) 在一个新构建的MediaPlayer对象和一个调用了reset()方法的MediaPlayer对象之间有一个微小的但是十分重要的差别。在处于Idle状态时,调用getCurrentPosition()getDuration()getVideoHeight(),getVideoWidth()setAudioStreamType(int)setLooping(boolean)setVolume(float, float),pause()start()stop()seekTo(int)prepare() 或者 prepareAsync() 方法都是编程错误。当一个MediaPlayer对象刚被构建的时候,内部的播放引擎和对象的状态都没有改变,在这个时候调用以上的那些方法,框架将无法回调客户端程序注册的OnErrorListener.onError()方法;但若这个MediaPlayer对象调用了reset()方法之后,再调用以上的那些方法,内部的播放引擎就会回调客户端程序注册的OnErrorListener.onError()方法了,并将错误的状态传入。

1.2) 我们建议,一旦一个MediaPlayer对象不再被使用,应立即调用release()方法来释放在内部的播放引擎中与这个MediaPlayer对象关联的资源。资源可能包括如硬件加速组件的单态组件,若没有调用release()方法可能会导致之后的MediaPlayer对象实例无法使用这种单态硬件资源,从而退回到软件实现或运行失败。一旦MediaPlayer对象进入了End状态,它不能再被使用,也没有办法再迁移到其它状态。

1.3) 此外,使用new操作符创建的MediaPlayer对象处于Idle状态,而那些通过重载的create()便利方法创建的MediaPlayer对象却不是处于Idle状态。事实上,如果成功调用了重载的create()方法,那么这些对象已经是Prepare状态了。 


2) 在一般情况下,由于种种原因一些播放控制操作可能会失败,如不支持的音频/视频格式,缺少隔行扫描的音频/视频,分辨率太高,流超时等原因,等等。因此,错误报告和恢复在这种情况下是非常重要的。有时,由于编程错误,在处于无效状态的情况下调用了一个播放控制操作可能发生。在所有这些错误条件下,内部的播放引擎会调用一个由客户端程序员提供的OnErrorListener.onError()方法。客户端程序员可以通过调用MediaPlayer.setOnErrorListener(android.media.MediaPlayer.OnErrorListener)方法来注册OnErrorListener.

2.1) 一旦发生错误,MediaPlayer对象会进入到Error状态。

2.2) 为了重用一个处于Error状态的MediaPlayer对象,可以调用reset()方法来把这个对象恢复成Idle状态。

2.3) 注册一个OnErrorListener来获知内部播放引擎发生的错误是好的编程习惯。

2.4) 在不合法的状态下调用一些方法,如prepare()prepareAsync()setDataSource()方法会抛出IllegalStateException异常。 


3) 调用setDataSource(FileDescriptor)方法,或setDataSource(String)方法,或setDataSource(Context,Uri)方法,或setDataSource(FileDescriptor,long,long)方法会使处于Idle状态的对象迁移到Initialized状态。


3.1) 若当此MediaPlayer处于其它的状态下,调用setDataSource()方法,会抛出IllegalStateException异常。

3.2) 好的编程习惯是不要疏忽了调用setDataSource()方法的时候可能会抛出的IllegalArgumentException异常和IOException异常。 


4) 在开始播放之前,MediaPlayer对象必须要进入Prepared状态。

4.1) 有两种方法(同步和异步)可以使MediaPlayer对象进入Prepared状态:要么调用prepare()方法(同步),此方法返回就表示该MediaPlayer对象已经进入了Prepared状态;要么调用prepareAsync()方法(异步),此方法会使此MediaPlayer对象进入Preparing状态并返回,而内部的播放引擎会继续未完成的准备工作。当同步版本返回时或异步版本的准备工作完全完成时就会调用客户端程序员提供的OnPreparedListener.onPrepared()监听方法。可以调用MediaPlayer.setOnPreparedListener(android.media.MediaPlayer.OnPreparedListener)方法来注册OnPreparedListener.

4.2) Preparing是一个中间状态,在此状态下调用任何具备边影响的方法的结果都是未知的!

4.3) 在不合适的状态下调用prepare()prepareAsync()方法会抛出IllegalStateException异常。当MediaPlayer对象处于Prepared状态的时候,可以调整音频/视频的属性,如音量,播放时是否一直亮屏,循环播放等。 


5) 要开始播放,必须调用start()方法。当此方法成功返回时,MediaPlayer的对象处于Started状态。isPlaying()方法可以被调用来测试某个MediaPlayer对象是否在Started状态。

5.1) 当处于Started状态时,内部播放引擎会调用客户端程序员提供的OnBufferingUpdateListener.onBufferingUpdate()回调方法,此回调方法允许应用程序追踪流播放的缓冲的状态。

5.2) 对一个已经处于Started 状态的MediaPlayer对象调用start()方法没有影响。


6) 播放可以被暂停,停止,以及调整当前播放位置。当调用pause()方法并返回时,会使MediaPlayer对象进入Paused状态。注意StartedPaused状态的相互转换在内部的播放引擎中是异步的。所以可能需要一点时间在isPlaying()方法中更新状态,若在播放流内容,这段时间可能会有几秒钟。

6.1) 调用start()方法会让一个处于Paused状态的MediaPlayer对象从之前暂停的地方恢复播放。当调用start()方法返回的时候,MediaPlayer对象的状态会又变成Started状态。

6.2) 对一个已经处于Paused状态的MediaPlayer对象pause()方法没有影响。


7) 调用stop()方法会停止播放,并且还会让一个处于StartedPausedPreparedPlaybackCompleted状态的MediaPlayer进入Stopped状态。

7.1) 对一个已经处于Stopped状态的MediaPlayer对象stop()方法没有影响。


8) 调用seekTo()方法可以调整播放的位置。

8.1) seekTo(int)方法是异步执行的,所以它可以马上返回,但是实际的定位播放操作可能需要一段时间才能完成,尤其是播放流形式的音频/视频。当实际的定位播放操作完成之后,内部的播放引擎会调用客户端程序员提供的OnSeekComplete.onSeekComplete()回调方法。可以通过setOnSeekCompleteListener(OnSeekCompleteListener)方法注册。

8.2) 注意,seekTo(int)方法也可以在其它状态下调用,比如PreparedPausedPlaybackCompleted状态。此外,目前的播放位置,实际可以调用getCurrentPosition()方法得到,它可以帮助如音乐播放器的应用程序不断更新播放进度


9) 当播放到流的末尾,播放就完成了。

9.1) 如果调用了setLooping(boolean)方法开启了循环模式,那么这个MediaPlayer对象会重新进入Started状态。

9.2) 若没有开启循环模式,那么内部的播放引擎会调用客户端程序员提供的OnCompletion.onCompletion()回调方法。可以通过调用MediaPlayer.setOnCompletionListener(OnCompletionListener)方法来设置。内部的播放引擎一旦调用了OnCompletion.onCompletion()回调方法,说明这个MediaPlayer对象进入了PlaybackCompleted状态。

9.3) 当处于PlaybackCompleted状态的时候,可以再调用start()方法来让这个MediaPlayer对象再进入Started状态。 

2012年10月24日 星期三

android 檔案選擇器寫法


package tw.Goocue;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Main extends Activity {
   @Override
   public void onCreate(Bundle icicle)
   {
     // TODO Auto-generated method stub
     super.onCreate(icicle);
        setContentView(R.layout.main);
       
        Button b = (Button)this.findViewById(R.id.b1);
       
        b.setOnClickListener( new OnClickListener(){
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
               
                // 建立 "選擇檔案 Action" 的 Intent
                Intent intent = new Intent( Intent.ACTION_GET_CONTENT );
               
                // 過濾檔案格式
                intent.setType( "*/*" );
               
                // 建立 "檔案選擇器" 的 Intent  (第二個參數: 選擇器的標題)
                Intent destIntent = Intent.createChooser( intent, "選擇檔案" );
               
                // 切換到檔案選擇器 (它的處理結果, 會觸發 onActivityResult 事件)
                startActivityForResult( destIntent, 0 );
            }
        });
   }
   
   @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         
         // TODO Auto-generated method stub
         super.onActivityResult(requestCode, resultCode, data);
         
         // 有選擇檔案
         if ( resultCode == RESULT_OK )
         {
             // 取得檔案的 Uri
             Uri uri = data.getData();
             if( uri != null )
             {
               Cursor cursor = this.getContentResolver().query(uri, null, null, null, null);
                  cursor.moveToFirst();
                 
                  for (int i = 0; i < cursor.getColumnCount(); i++) {
                   
                   
                   setTitle( i+"-"+cursor.getString(1));
                   }
                 // 利用 Uri 顯示 ImageView 圖片
                // setTitle( uri.toString() );
             }
             else
             {
                 setTitle("無效的檔案路徑 !!");
             }
         }
         else
         {
             setTitle("取消選擇檔案 !!");
         }
     }

}

2012年10月6日 星期六

反組議Android程式--提供學習

工具
dex2jar-->將dex轉成jar檔
JD-GUI-->將class轉成可閱讀的java檔

1 將已上檔案下載且安裝!
2 找到要解析的apk檔!
3 將apk檔置於dex2jar解壓縮後的目錄
4 切換到windows下的的cmd模式
5於dex2jarr解壓縮目錄執行指令 dex2jar.bat xxx.apk
6 如要轉檔的apk為Ch15_4.apk  指令: dex2jar.bat Ch15_4.apk
7 如成功會出現以下畫面:



8 當前目錄下會找到xxx.jar如轉檔名為Ch15_4.apk,產生的jar檔為Ch15_4.jar
9 解開此壓縮檔內含有反組議後的class檔
10 開啟JD-GUI將class檔開啟如下:
11 就可看到反組議後的程式啦


至於akp檔去哪下載,有許多文章可以去google搜一搜
我附上測試用的Ch15_4.apk



2012年10月3日 星期三

Android 去除標題

requestWindowFeature(Window.FEATURE_NO_TITLE);
要放在onCreate第一行

2012年9月22日 星期六

Android 使用StateListDrawablec換樣式

StateListDrawable可以根据View的不同状态,更换不同的背景

可以应用如EditText,Button等中,以Button为例

系统中默认的按钮被按下的颜色和未点击时的颜色不一样,该种实现可以用Java代码和XML实现

<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android"

android:constantSize=["true" | "false"]

android:dither=["true" | "false"]

android:variablePadding=["true" | "false"] >

<item

android:drawable="@[package:]drawable/drawable_resource"

android:state_pressed=["true" | "false"]

android:state_focused=["true" | "false"]

android:state_selected=["true" | "false"]

android:state_active=["true" | "false"]

android:state_checkable=["true" | "false"]

android:state_checked=["true" | "false"]

android:state_enabled=["true" | "false"]

android:state_window_focused=["true" | "false"] />

</selector>


下面对应的具体实例,由于是做背景用,该xml将放于/res/drawable下面
StateList中第一个匹配当前状态的item会被使用。因此,如果第一个item没有任何状态特性的话,那么它将每次都被使用,这也是为什么默认的值必须总是在最后
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" android:drawable="@drawable/btn_selected"/>
    <item android:state_focused="true" android:drawable="@drawable/btn_selected"/>
    <item android:state_enabled="true" android:drawable="@drawable/btn_normal"/>
    <item  android:drawable="@drawable/btn_normal" />
</selector>

在Button的xml中进行加载:
 <Button
            android:id="@+id/canel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/btn_cancel"
            android:layout_margin="10dip"
            android:layout_weight="1"
            android:textColor="#ffffffff"
            android:textSize="15sp"
            android:background="@drawable/button_drawable"
            />
   

2012年9月20日 星期四

Java7新功能整理之一


Java 7
新功能整理之一
一 switch 新增 String 作為條件 但要注意 String為Null,與字串大小寫
二 數字可使用Using underscores (_) 如 flaot value1 = 123_56.178_22f
小心如下錯誤寫法
 long productKey = _12345_67890_09876_54321L;
   float pi = 3._14_15F;
   long licenseNumber = 123_456_789_L;

三 Using the try-with-resources block:過去使用資源後需要自行關閉現在會自動關閉(Automated Resource Management)
Files 出於java新版的套件 java.nio.file.Files;
 try (BufferedReader inputReader = Files.newBufferedReader(
                        Paths.get(new URI ("file:///C:/home/docs/users.txt")),
                        Charset.defaultCharset());
                BufferedWriter outputWriter = Files.newBufferedWriter(
                        Paths.get(new URI("file:///C:/home/docs/users.bak")),
                        Charset.defaultCharset())) {
            String inputLine;
            while ((inputLine = inputReader.readLine()) != null) {
                outputWriter.write(inputLine);
                outputWriter.newLine();}
            System.out.println("Copy complete!");}
catch (URISyntaxException | IOException ex) {
            ex.printStackTrace();
}
也可自行實作一個ARM物件,需實作AutoCloseable

四 multiple exception:
public class MultipleExceptions {
    private static final Logger logger = Logger.getLogger("log.
txt");
    public static void main(String[] args) {
        System.out.print("Enter a number: ");
        try {
            Scanner scanner = new Scanner(System.in);
            int number = scanner.nextInt();
            if (number < 0) {
                throw new InvalidParameter();
}
            System.out.println("The number is: " + number);
}
catch (InputMismatchException | InvalidParameter e) {
            logger.log(Level.INFO, "Invalid input, try again");
}
}
要注意
1 使用Multiple Exceptions 不可將其父類別至於選項中如(InputMismatchException | Exception e)
2 catch 內的變數不可再重新指向
3 Java 7 多了一個AssertionError 實體

五 Using the diamond operator <>
過去  List<String> list = new ArrayList(); 會出現警告訊息
現在可改成List<String> list = new ArrayList<>();即可
如不想發出警告可使用
@SuppressWarnings({ "unused", "unchecked", "rawtypes" })

@SafeVarargs 方法使用範形不想發出警告,最好用於方法變數是reifiable Type

蝦咪是reifiable type

int is a reifiable type (primitive type)
List is a reifiable type (raw type)
List<?> is a reifiable type (parameterized type with unbound wildcards)
List<String> is not a reifiable type (generic type)
Class<?> is a reifiable type
Class<String> is not a reifiable type

2012年7月7日 星期六

android桌布相關

  1. final WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);   
  2. final Drawable wallpaperDrawable = wallpaperManager.getDrawable(); 
  3. 可取得桌布圖
  4.   int newWidth = instance.getDesiredMinimumWidth(); 
             int newHeight = instance.getDesiredMinimumHeight();  
  5. 可取的桌面長寬

2012年7月4日 星期三

onFling 沒反應嗎?
記的onDown 要 return true;ㄚㄚㄚㄚ!!!

2012年7月1日 星期日

設定view的可見度

android view的setVisibility方法值的意思
有三个值 visibility  One of VISIBLE, INVISIBLE, or GONE.

常量值为0,意思是可见的
常量值为4,意思是不可见的
常量值为8,意思是不可见的,而且不占用布局空间

2012年6月18日 星期一

使用Picasa APi 要注意的東西

gdata-core-1.0.jar
gdata-media-1.0.jar
gdata-photos-2.0.jar
*guava-12.0.jar
mail.jar
*gdata-photos-meta-2.0.jar
星星的特重要!!~google有點OOXX~~API差點動不了!!
他的API內好像沒說明需要這些jar而且有些jar沒匯入也不會跟你說錯
只能奔淚去google~~以上匯入了基本上因該就可以運作了!
以上一定要匯入的jar

2012年6月5日 星期二

has leaked ServiceConnection

如出現如下錯誤 has leaked ServiceConnection

請記得:unbindService
bindService 與 unbindService是成對的

2012年5月25日 星期五

不想讓Activity在旋轉螢幕時被自動轉向

如果不想讓Activity在旋轉螢幕時被自動轉向,可以在AndroidManifest.xml中設定Activity的屬性:

  • android:screenOrientation="portrait" (指定為直向)
  • android:configChanges="keyboard|keyboardHidden|orientation" (告訴系統,我要自己處理轉向問題)
<activity
            android:label="@string/app_name"
            android:name=".RotationDeviceDemoActivity" 
            android:configChanges="keyboard|keyboardHidden|orientation" 
            android:screenOrientation="portrait">
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
</activity>

2012年3月7日 星期三

2012年2月29日 星期三

SRPG我心中的經典超級機器人大戰系列(內有影片)

SRPG我心中的經典超級機器人大戰系列(TV-Game): 當年超級機器人大戰陪我度過了許多寒暑阿,青春阿阿…. 超級機器人大戰介紹: 超級機器人大戰是日本萬代的子公司帕布雷斯特公司出品回合制戰棋類遊戲系列。第一個機戰作品是1991年在任天堂掌上型遊戲機Game Boy上發行的, 本系列最大魅力就是集中了很受歡迎的機器人動畫作品中的人物和機器人,使用原作的配音演員進行配音。 看看可控制機器人名單就熱血了!(ps.女生可能沒感覺) 無敵鐵金剛、蓋特機器人、機動戰士鋼彈系列作品、新世紀福音戰士 、勇者王、勇者萊汀等等… 主要遊戲是回合戰棋方式運作,系統特色有1 可改裝機器人 2 部分角色可互換機器人 。 經典原因:1 當紅機器人太熱血了 2 多支線系統耐玩度提升 3 可改裝機器人

經典遊戲-RPG FF系列 內有影片

RPG角色扮演經典:
FINAL FANTASY系列(太空戰士或最終幻想) (TV-Game or PC):
《太空戰士》(Final Fantasy)是一個由坂口博信創造的電子遊戲機角色扮演遊戲。史克威爾公司(現為史克威爾艾尼克斯)於1987年在日本開發與發表,於1990年在北美由美國的任天堂發表。
每一代都有其特色最火的當屬第七代銷量為972萬套,當年轟動PS遊戲主機後來還移植到PC,一直到最近還有續做出來真是金雞母阿。
經典原因:
1 第一款3D版的太空戰士。
2 故事架構完整且淒美讓人感動。
3 人物刻劃細膩。
3 動畫配樂精美。
4 招喚獸系統太酷啦。
以上幾點不玩就對不起父母啦!

線上修課 麻省理工發證書

線上修課 麻省理工發證書

今天新學的去背(有圖喔!)


晚點在發一些去背的教學影片!順便熟練一下也幫自己做筆記
去背之後
 去背之前

背景圖加了一點光隱的效果感覺還不錯!
另外背景圖是網路上抓的!出處為Photoshop设计制作电影中科幻效果风暴门图片教程只用於教學用途