Android四大組件

來源:互聯網
上載者:User

標籤:

Activity:

      onCreat() onStart() onRestart() onResume() onPause() onStop() onDestory()

      四個基本狀態:活動中 暫停 停止 待用

    standard模式 建立新的activity

    singleTop模式 調用頂部activity時不建立新的

      singleTask模式一個activity執行個體只存在一個

      singleInstance模式建立Task

       恢複activity onSaveInstanceState() onCreat(){ savedInstanceState.get()}

 

    Intent:

      action data category type component extras flag

      顯示Intent setComponent() setClass()

       隱式Intent InterFilter

    BroadcastReceeiver:

      繼承BroadcastReceiver 實現onReceiver() 函數

  靜態註冊AndroidManifest.xml 動態註冊 onCreat() 或onStart()中註冊 onStop() 或onDestory()中撤銷

  普通廣播 有序廣播(intent-filter 中priority)

Service:

  onCreate() onStartCommand() onBind( return null ) onDestroy()

       startService()->onCreate()->onStartCommand()->running-> onDestroy()

       啟動形式的service 繼承Service(主線程中執行)繼承IntentService(建立新的線程串列執行) 只需實現onHandleIntent() 方法

       bindService()->onCreate()->onBind( return IBinder )-> binded-> onUnbind()->onDestroy()

       綁定形式的service繼承Service 建立一個inner class繼承Binder 建立getService(return outerService.this)方法

       ServiceConnection類:onServiceConnected(),onServiceDisconnected()

    ContentPrivoder:

      onCreate() query() update() getType() delete() insert() Uri.parse(String)

      getContentResolver() android:authorities

Android四大組件

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.