ä¸æ¨æ¥ãããã«Android 7.1.1ã®OTAãéå§ããã¾ãããã ç§ã®Nexus5Xã«ãå±ããã®ã§ãæ©éã¤ã³ã¹ãã¼ã«ãã¾ããã
Android 7.1ã§ç®çã®æ©è½ã¨ãªãã®ã¯ãApp Shortcutsãªã®ã§ã¯ãªãã§ããããï¼ ã¨ãããã¨ã§è©¦ãã¦ã¿ã¾ããã å ¬å¼ã®APIã¬ã¤ããè¦ã¦ããã°ããããç°¡åã«å®è£ ã§ãã¾ãï¼
App Shortcuts æ¦ç¥
App Shortcutsã¯ã欲ããæ å ±ã«ããã«ã¢ã¯ã»ã¹ããããã®æ©è½ã§ãã ã©ã³ãã£ã¼ã¢ã¤ã³ã³ãé·æ¼ããããã¨ã§ãã·ã§ã¼ãã«ããä¸è¦§ã表示ããã¾ãã ã·ã§ã¼ãã«ãããæ¼ãã°ããã®ã¢ããªã®ç¹å®ã®ç»é¢ã«ããã«ãã©ãçããã¨ãããã®ã§ãã
次ã®å³ã®ãããªã¤ã¡ã¼ã¸ã§ãã å°å³ã¢ããªã®ã©ã³ãã£ã¼ã¢ã¤ã³ã³ãé·æ¼ãããã¨ãWorkããHomeãã®ã·ã§ã¼ãã«ããã表示ããã¾ãã ãWorkãã·ã§ã¼ãã«ãããæ¼ãã¨åã«å°å³ã¢ããªãèµ·åããã¨ãã¨ã¯ç°ãªããç¾å¨å°ããè·å ´ã¾ã§ã®éæ¡å ãããã«å§ã¾ãã¾ãã
åãã®è©±ãããã¨ãåã·ã§ã¼ãã«ããã¯ã²ã¨ã¤ã®ã¤ã³ãã³ããæã£ã¦ãããã·ã§ã¼ãã«ãããæ¼ãããã¨ãã®ã¤ã³ãã³ããçºè¡ãããã¨ããä»çµã¿ã§ãã
App Shortcutsã«ããã¦ãã·ã§ã¼ãã«ããã«ã¯2種é¡ããã¾ãã éçã·ã§ã¼ãã«ããã¨åçã·ã§ã¼ãã«ããã§ãã
éçã·ã§ã¼ãã«ããã¯ãXMLã§ã·ã§ã¼ãã«ãããå®ç¾©ãã¦ããæ¹æ³ã§ãã
ä¸æ¹ãåçã·ã§ã¼ãã«ããã¯ãããã°ã©ã ã³ã¼ãã§å®ç¾©ãã¾ãã ãåçãã®è¨èã®ã¨ãããã¢ããªã®å®è¡ä¸ã«ç¶æ³ã«å¿ãã¦ã·ã§ã¼ãã«ããã追å ãæ´æ°ãåé¤ãå¯è½ã§ãã
éçã·ã§ã¼ãã«ãã
XMLã§ã·ã§ã¼ãã«ããããããããæºåãã¦ããæ¹æ³ã§ãã res/xmlã®ä¸ã«ã·ã§ã¼ãã«ããä¸è¦§ãå®ç¾©ããXMLãã¡ã¤ã«ãä½æãã¾ãã ããã§ã¯shortcuts.xmlã¨ããååã®ãã¡ã¤ã«ãä½æãã¾ãã ãã®å 容ã¯ãä¸è¨ãæå°æ§æã§ãã
<?xml version="1.0" encoding="utf-8"?> <shortcuts xmlns:android="http://schemas.android.com/apk/res/android"> <shortcut android:shortcutId="launch" android:shortcutShortLabel="@string/launcher_short"> <intent android:action="android.intent.action.VIEW" android:targetPackage="com.example.app" android:targetClass="com.example.app.MainActivity" /> </shortcut> </shortcuts>
ã«ã¼ãã«shortcuts
è¦ç´ ãããããã®ç´ä¸ã«ããã¤ãã®shortcut
è¦ç´ ãå«ã¿ã¾ãã
shortcut
è¦ç´ ã¯ãå°ãªãã¨ãandroid:shortcutId
, android:shortcutShortLabel
ã®å±æ§ãæã¤å¿
è¦ãããããã§ãã
ããã¦shortcut
è¦ç´ ã¯intent
è¦ç´ ãæã¡ã¾ãã
ã·ã§ã¼ãã«ãããæ¼ãããã¨ãã«ããã®ã¤ã³ãã³ããçºè¡ããã¾ãã
ãã®ä¾ã§ã¯ãæå®ããã¢ã¯ãã£ããã£ãèµ·åããã ãã§ãã
次ã«ãèªåã®ã¢ããªãã·ã§ã¼ãã«ãããæã£ã¦ãããã¨ãç¥ãããããã«AndroidManifest.xmlãç·¨éãã¾ãã
ã©ã³ãã£ã¼ããèµ·åãããã¢ã¯ãã£ããã£å
ã«ãmeta
è¦ç´ ã追å ãã¾ãã
<activity android:name=".MainActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcuts" /> </activity>
ããã§éçã·ã§ã¼ãã«ããã®æºåã¯å®äºã§ãã ãã«ããã¦å®è¡ããã¨ãã次ã®ããã«ã·ã§ã¼ãã«ããã確èªã§ããã¯ãã§ãã
shortcut
è¦ç´ ã«android:shortcutLongLabel
å±æ§ã¨android:icon
å±æ§ã追å ãã¦ã¿ã¾ãã
<?xml version="1.0" encoding="utf-8"?> <shortcuts xmlns:android="http://schemas.android.com/apk/res/android"> <shortcut android:shortcutId="launch" android:shortcutShortLabel="@string/launcher_short" android:shortcutLongLabel="@string/launcher_long" android:icon="@mipmap/ic_launcher"> <intent android:action="android.intent.action.VIEW" android:targetPackage="com.example.app" android:targetClass="com.example.comm.MainActivity" /> </shortcut> </shortcuts>
ãã«ããã¦å®è¡ããã¨ãä¸è¨ã®ããã«å¤ãã£ã¦ãã¾ãã
ã·ã§ã¼ãã«ããä¸è¦§ã«è¡¨ç¤ºãããã©ãã«ãandroid:shortcutLongLabel
ã«å¯¾å¿ãã¦ããããã§ãã
android:shortcutShortLabel
ã¯ã©ãã§ä½¿ããããã¨è¨ãã¨ãã·ã§ã¼ãã«ããä¸è¦§ã§ã·ã§ã¼ãã«ãããé·æ¼ãããã¨ãã·ã§ã¼ãã«ããããã¼ã ç»é¢ã«è¨ç½®ã§ããã®ã§ããããã®ã¨ãã®ã©ãã«ã«ä½¿ç¨ããã¾ãã
ã¡ãªã¿ã«ãã·ã§ã¼ãã«ããã®ã¢ã¤ã³ã³ã§ããããã¶ã¤ã³ã»ã¬ã¤ãã©ã¤ã³ï¼PDFï¼ãæä¾ããã¦ããã®ã§ãããã«å¾ãã¹ãã§ãããï¼ãã®ä¾ã¯ãã¡ãã¡ãªãã¶ã¤ã³ï¼ã
ä»åãç§ã趣å³ã§éçºãã¦ããã夢ã¨éæ³ã®å¾ ã¡æéãã§ã¯ã次ã®ããã«éçã·ã§ã¼ãã«ãããå®ç¾©ãã¦ãã¾ãï¼ä¸é¨ãä¾ç¤ºç¨ã«æ¹å¤ï¼ã
<?xml version="1.0" encoding="utf-8"?> <shortcuts xmlns:android="http://schemas.android.com/apk/res/android"> <shortcut android:shortcutId="land" android:enabled="true" android:icon="@drawable/ic_land" android:shortcutShortLabel="@string/label_land_wait_time" android:shortcutLongLabel="@string/label_land_wait_time"> <intent android:action="android.intent.action.VIEW" android:data="app://com.example.app/land_wait_time" /> </shortcut> <shortcut android:shortcutId="sea" android:enabled="true" android:icon="@drawable/ic_sea" android:shortcutShortLabel="@string/label_sea_wait_time" android:shortcutLongLabel="@string/label_sea_wait_time"> <intent android:action="android.intent.action.VIEW" android:data="app://com.example.app/sea_wait_time" /> </shortcut> </shortcuts>
ã·ã§ã¼ãã«ãããæ¼ãã¨ãURLã¸ã®ã¢ã¯ã»ã¹ãèµ·ãããã¢ããªããããããã¯ããã¨ããå ·åã§ãã
åçã·ã§ã¼ãã«ãã
åçã·ã§ã¼ãã«ããã®ã¿ãæä¾ããå ´åã¯XMLã¯ä¸è¦ã§ãã ããã°ã©ã ã³ã¼ãã§ã·ã§ã¼ãã«ããã表ç¾ãã追å ãæ´æ°ãåé¤ã¨ãã£ãæä½ãè¡ãã¾ãã
éè¦ãªAPIã¯ShortcutInfo
ã¨ShortcutManager
ã§ãã
ã¾ãShortcutInfo
ã§ã·ã§ã¼ãã«ããã表ç¾ãã¾ãã
val shortcutInfo: ShortcutInfo = ShortcutInfo.Builder(context, "lastVisitedScreen") .setShortLabel(lastVisitedScreenShortName) .setLongLabel(lastVisitedScreenLongName) .setIcon(Icon.createWithResources(context, R.drawable.ic_history) .setIntent(Intent(Intent.ACTION_VIEW, lastVisitedScreenUri)) .build()
ä¸è¨ã®ããã«ãShortcutInfo.Builder
ã¨ãããã«ãã¼ã®ã¤ã³ã¹ã¿ã³ã¹ãåå¾ããã¡ã½ãããã§ã¼ã³ãå½¢æãã·ã§ã¼ãã«ããã®è¨å®ãã»ãããã¦ããã¾ãã
ã¡ãªã¿ã«ããã®ã³ã¼ãã¯Kotlinã§è¨è¿°ãã¦ãã¾ãã
次ã«ããã®shortcutInfo
ãShortcutManager
ã使ã£ã¦è¿½å ãã¾ãããã
ä¸è¨ããã®ã³ã¼ãã§ãã
val shortcutManager: ShortcutManager = context.getSystemService(ShortcutManager::class.java) shortcutManager.setDynamicShortcuts(listOf(shortcutInfo))
ã·ã§ã¼ãã«ããã®è¿½å ã¡ã½ããsetDynamicShortcuts
ã¨æ´æ°ã¡ã½ããupdateShortcuts
ã¯ãShortcutInfo
ã®ãªã¹ããåãåãã®ã§ãKotlinæ¨æºé¢æ°listOf
ã§ãªã¹ãã«ãã¦ãã¾ãã
åé¤ã¡ã½ããremoveDynamicShortcuts
ã¯ãæååï¼ã·ã§ã¼ãã«ããIDï¼ã®ãªã¹ããåãåãã¾ãã
ã夢ã¨éæ³ã®å¾ ã¡æéãã§ã¯ãåçã·ã§ã¼ãã«ããã使ã£ã¦ãæå¾ã«è¡¨ç¤ºããç»é¢ã¸ã®ã·ã§ã¼ãã«ãããæä¾ãã¦ãã¾ãã ããã¯éçã·ã§ã¼ãã«ããã§ã¯å®ç¾ã§ããªãæ©è½ã§ãã
æã®ã¢ã¤ã³ã³ã®ã·ã§ã¼ãã«ããããæå¾ã«è¡¨ç¤ºããç»é¢ã¸ã®ã·ã§ã¼ãã«ããã§ãã
ã¾ã¨ã
- Android 7.1.1ã®é ä¿¡ãå§ã¾ãã¾ãã
- App Shortcutsã¯ã·ã§ã¼ãã«ãããæä¾ããæ©è½ã§Android 7.1ã§å°å ¥ããã¾ãã
- ã·ã§ã¼ãã«ããã«ã¯éçã·ã§ã¼ãã«ããã¨åçã·ã§ã¼ãã«ãããããã¾ã
- éçã·ã§ã¼ãã«ããã¯ãXMLã§äºåã«å®ç¾©ãã¦ããã¾ã
- åçã·ã§ã¼ãã«ããã¯ãããã°ã©ã ã§åçã«å®ç¾©ãã¾ã
Androidã§ã®ä½é¨ããã便å©ã«ãªãããã§ããï¼ï¼ï¼ï¼
ããã«App Shortcutsãå¦ã³ãã人ã¯å ¬å¼ã®APIã¬ã¤ããåç §ãã¦ãã ããã