跳到主要內容

Android O 多了什麼新東西 ??

Background Execution Limits

1. 大部份在 AndroidMenifast 宣告的 Implicit BroadcastReceiver 不會被呼叫,但有些還是可以 work,如以下:
    • BOOT_COMPL
    • ETELOCALE_CHANGED
    • USB_DEVICE_ATTACHED
    • Explicit BroadcastReceiver 沒什麼改變,還是可正常發送。Runtime Implicit BroadcastReceiver 也沒什麼改變。
      2. Service 也有些改變,如以下: 
      • Run minimally after the app has been background (這要開發者怎麼決定哪些是一定要在背景執行的阿…)
      • App 在背景時,不能使用 startService() 跟 PendingIntent
      • Foreground service 不變,多了新 API 可以使用,NotificationManager#startServiceInForeground
      3. When you app enter cache state with no active component, weak locks be automatically released.

      4. Location
      • Background Location Limited updates, few times per hour
      • Passive Location Unchanged (這句在說啥?)
      • 有其他 app 在前景使用 Location update,你的 background location 更新的頻率會跟前景一樣 (所以重點就是要有 app 在前景要 location 的資料!)
      • Foreground Location 沒改變

      Settings.Secure.ANDROID_ID

      其實這個我看不懂他在說什麼,之前完全沒碰過…
      • pre-O:每個 app 的 ID 都一樣
      • post-O:每個 app 都會有個獨立的 ID (影片說由 Google Play Service 管嗎?)

      Account access

      • 不能用 GET_ACCOUNTS 這個 permission 了
      • 要改用 newChooseAccountIntent (AccountManager 跟 Google Play Service library 都有)

      Notification Channel

      • 大意就是提供一個統一的用法讓使用者管理 notification
      • App 設定在 Android O 的話,至少要實作一組 notification channel
      • 不是設定在 Android O 的話就不用管這個
      • 詳情請看官方介紹

      Autofill Framework

       讓使用者便於輸入使用者相關的個人資訊,減少使用者打錯的機會,並節省時間
      • Addresses
      • Credit card information
      • user name
      • password
      • 支援 custom view,但要額外實作一些 method
      • 詳情請看官方介紹

      Picture in Picture

        在 Android M 時 PIP mode 只支援 Android TV,在 Android O 所有的 device 都支援 PIP mode 了。新 API PictureInPictureArgs 可以設定 PIP mode,如畫面比例等。詳情請看官方介紹。

      Multi Display Support

      Android O 有支援 multi display。假如你的 app 設定 Android O,執行在有 multi display 的 device 上時,使用者可以自由切換 activity 要在哪個 display 顯示。不過開發者在發佈 app 最好要測試過這個功能。

      Font Resources

      簡單說就是 resource 終於有 font 可以用了,如 R.font.your_font。詳情請看官方介紹。


      這篇只是重點節錄上面 youtube 影片的內容,新功能還是要親自使用過後才會比較有感覺喔 (我也不知道自己哪時候會試,我到現在都還沒有 Android N 的 device…)

      參考資料

      Android O preview
      Android O Features and APIs

            留言

            這個網誌中的熱門文章

            動態更新 ViewPager 的目前顯示頁面

                    ViewPager 在 Android 裡是一個很好用的元件,使用者只要左右滑動,就可以顯示多頁的資訊。假如你的資料是從網路取得,如圖片,當使用者滑到還沒載入完成的頁面時,該怎麼辦呢?         雖然 ViewPager 會動態更新頁面,但是當下顯示的頁面是不會更新的。要達到上述的目的,我們要做一些事。ViewPager 主要是由 PagerAdapter 來處理內部的資料的,因此我們要從它下手。         PagerAdapter 有一個 method:getItemPosition。看 API 說明應該是用來判斷目前頁面的內容位置是否有變,但是也可以用它來滿足我們的要求,pseudo code 如下: public int getItemPosition(Object object) {         if ( 你的資料準備好了 )         {                 return POSITION_NONE;         }         else         {                 // 資料還沒準備好,此頁面維持不變                 return POSITION_UNCHANGED;         } }         雖然 overwrite 了 getItemPosition,但是這個 method 並不是我們主動去 invoke 的,PagerAdapter 提供了另一個 method 可以讓我們通...

            透明背景的 AlertDialog

                    Android dialog 預設都會有一個背景底色,要怎麼把它去掉呢?其實直接改 AlertDialog 的 style 就可以了,但我改好久…以下的範例是使用了 Support v7 AppCompat 的 theme,其他 theme 我不知道可不可以,有興趣的人可以試試看。 <style name="TransparentDialog" parent="@style/Base.Theme.AppCompat.Dialog"> <item name="android:windowFrame">@null</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowIsFloating">true</item> <item name="android:windowTitleStyle">@null</item> <item name="android:background">@android:color/transparent</item> <item name="android:windowNoTitle">true</item> <item name="android:alertDialogStyle">@style/TransparentDialog.Color</item> </style> <style name="TransparentDialog.Color" parent="@style/Base.Theme.AppCompat.Dialog"> <item name="androi...