新增多媒体类型(一)

一、Gallery应用

1、启动acitity(com.cooliris/media/Gallery.java)

///////////////////////////////AndroidManifes.xml//////////////////////////////////
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name="com.cooliris.media.Gallery" android:label="@string/app_name"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
            android:configChanges="keyboardHidden|orientation"
            android:clearTaskOnLaunch="true" android:noHistory="false"
            android:stateNotNeeded="true">
.................................................

2、isViewIntent()判断action("android.intent.action.MAIN")是不是视图"android.intent.action.VIEW",结果为否,跳过

3、if (isViewIntent() && getInt....也跳过

4、创建RenderView视图

5、sendInitialMessage()向本actitity发送消息

6、第66行接收消息,(private final Handler handler = new Handler() {.......),执行checkStorage

    private final Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case CHECK_STORAGE:
                    checkStorage();
                    break;
                case HANDLE_INTENT:
                    initializeDataSource();
                    break;
            }
        }
    };

7、checkStorage中mImageManagerHasStorageAfterDelay返回true,则直接跳到handler.sendEmptyMessage(HANDLE_INTENT);

    private void checkStorage() {
        mNumRetries++;
        mImageManagerHasStorageAfterDelay = ImageManager.hasStorage();
        if (!mImageManagerHasStorageAfterDelay && mNumRetries < NUM_STORAGE_CHECKS) {
            if (mNumRetries == 1) {
                int res;

                if (Environment.isExternalStorageRemovable()) {
                    res = Res.string.no_sd_card;
                } else {
                    res = Res.string.no_usb_storage;
                }

                mApp.showToast(getResources().getString(res), Toast.LENGTH_LONG);
            }
            handler.sendEmptyMessageDelayed(CHECK_STORAGE, 200);
        } else {

            handler.sendEmptyMessage(HANDLE_INTENT);
      }
    }

 8、第66行接收消息,(private final Handler handler = new Handler() {.......),执行initializeDataSource提取所有数据

 

 

 

你可能感兴趣的:(多媒体)