Upgrade to Pro — share decks privately, control downloads, hide ads and more …

App Shortcuts

C49eed1cf04caeb4de645d6d9117708d?s=47 takuaraki
November 28, 2016

App Shortcuts

関モバ #20 の発表資料です。

C49eed1cf04caeb4de645d6d9117708d?s=128

takuaraki

November 28, 2016
Tweet

Transcript

  1. "QQ4IPSUDVUT  !BSB@UBDL

  2. "CPVU.F '63:6 !BSB@UBDL

  3. 1JYFM w (PPHMFͷ७ਖ਼εϚʔτϑΥϯ w (PPHMF"TTJTUBOU w %BZESFBN w "OESPJE

  4. "OESPJE w "QQ4IPSUDVUT w *NBHF,FZCPBSE4VQQPSU w 3PVOE*DPO3FTPVSDFT

  5. "QQ4IPSUDVUT w ΞΠίϯ௕ԡ͠Ͱىಈ w ػೳͷγϣʔτΧοτ w γϣʔτΧοτ΋ΞΠ ίϯʹͰ͖Δ

  6. %FNP

  7. IUUQTHJUIVCDPNUBLVBSBLJ "QQ4IPSUDVU4BNQMF

  8. 4UBUJD4IPSUDVU <activity
 android:name=".MainActivity"
 android:label="@string/app_name"
 android:theme="@style/AppTheme.NoActionBar">
 <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> "OESPJE.BOJGFTUYNM
  9. 4UBUJD4IPSUDVU <?xml version="1.0" encoding="utf-8"?> <shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
 <shortcut
 android:shortcutId="createEmail"
 android:enabled="true"
 android:icon="@mipmap/ic_create_email"


    android:shortcutShortLabel="@string/email_shortcut_short_label"
 android:shortcutLongLabel="@string/email_shortcut_long_label"
 android:shortcutDisabledMessage="@string/disabled_message">
 <intent
 android:action="android.intent.action.VIEW"
 android:targetPackage="com.example.arakitaku"
 android:targetClass="com.example.arakitaku.EmailActivity" />
 </shortcut>
 </shortcuts> YNMTIPSUDVUTYNM
  10. 4UBUJD4IPSUDVU w JDPO w TIPSUDVU4IPSU-BCFM w TIPSUDVU-POH-BCFM w TIPSUDVU%JTBCMFE.FTTBHF

  11. 4UBUJD4IPSUDVU w JDPO w TIPSUDVU4IPSU-BCFM w TIPSUDVU-POH-BCFM w TIPSUDVU%JTBCMFE.FTTBHF

  12. 4UBUJD4IPSUDVU w JDPO w TIPSUDVU4IPSU-BCFM w TIPSUDVU-POH-BCFM w TIPSUDVU%JTBCMFE.FTTBHF

  13. 4UBUJD4IPSUDVU w JDPO w TIPSUDVU4IPSU-BCFM w TIPSUDVU-POH-BCFM w TIPSUDVU%JTBCMFE.FTTBHF

  14. 4UBUJD4IPSUDVU w JDPO w TIPSUDVU4IPSU-BCFM w TIPSUDVU-POH-BCFM w TIPSUDVU%JTBCMFE.FTTBHF

  15. %ZOBNJD4IPSUDVU ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
 ShortcutInfo ara_tack = new ShortcutInfo.Builder(this,

    "ara_tack")
 .setShortLabel("ara_tack")
 .setLongLabel("mail to ara_tack")
 .setIcon(Icon.createWithResource(this, R.mipmap.ic_create_email_a))
 .setIntent(
 EmailActivity.createIntent(this, "ara_tack")
 .setAction(Intent.ACTION_VIEW)
 )
 .build(); shortcutManager.setDynamicShortcuts(Arrays.asList(ara_tack)); .BJO"DUJWJUZKBWB
  16. %ZOBNJD4IPSUDVU ShortcutManager shortcutManager = getSystemService(ShortcutManager.class); ShortcutInfo ara_tack = new ShortcutInfo.Builder(this,

    "ara_tack")
 .setShortLabel("ara_tack")
 .setLongLabel("mail to ara_tack")
 .setIcon(Icon.createWithResource(this, R.mipmap.ic_create_email_a))
 .setIntent(
 EmailActivity.createIntent(this, "ara_tack")
 .setAction(Intent.ACTION_VIEW)
 )
 .build(); ShortcutInfo hashido = new ShortcutInfo.Builder(this, “hashido”)…… ShortcutInfo n_morioka = new ShortcutInfo.Builder(this, “n_morioka”)…… shortcutManager.setDynamicShortcuts(Arrays.asList(
 ara_tack, 
 hashido, 
 n_morioka
 )); .BJO"DUJWJUZKBWB
  17. %ZOBNJD4IPSUDVU ShortcutManager shortcutManager = getSystemService(ShortcutManager.class); ShortcutInfo kan = new ShortcutInfo.Builder(this,

    “kan”)…… ShortcutInfo sai = new ShortcutInfo.Builder(this, “sai”)…… ShortcutInfo mobairu = new ShortcutInfo.Builder(this, “mobairu”)…… ShortcutInfo apuri = new ShortcutInfo.Builder(this, “apuri”)…… ShortcutInfo kenkyu = new ShortcutInfo.Builder(this, “kenkyu”)…… ShortcutInfo kai = new ShortcutInfo.Builder(this, “kai”)…… // IllegalArgumentException will be thrown. // Max shortcut num is 5. (include static shortcuts)
 shortcutManager.setDynamicShortcuts(Arrays.asList(
 kan,
 sai,
 mobairu,
 apuri,
 kenkyu,
 kai
 )); .BJO"DUJWJUZKBWB
  18. %ZOBNJD4IPSUDVU // List<ShortcutInfo> shortcutInfos;
 // List<String> shortcutIds;
 // set
 shortcutManager.setDynamicShortcuts(shortcutInfos);

    
 // add
 shortcutManager.addDynamicShortcuts(shortcutInfos);
 
 // update
 shortcutManager.updateShortcuts(shortcutInfos);
 
 // remove specific
 shortcutManager.removeDynamicShortcuts(shortcutIds);
 
 // remove all
 shortcutManager.removeAllDynamicShortcuts();
 
 // disable
 shortcutManager.disableShortcuts(shortcutIds); .BJO"DUJWJUZKBWB
  19. %ZOBNJD4IPSUDVU ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
 ShortcutInfo n_morioka = new ShortcutInfo.Builder(this,

    "n_morioka")
 .setShortLabel("n_morioka")
 .setLongLabel("mail to n_morioka")
 .setIcon(Icon.createWithResource(this, R.mipmap.ic_create_email_n))
 // Multiple Intent can be set
 .setIntents(new Intent[]{
 MainActivity.createIntent(this)
 .setAction(Intent.ACTION_VIEW),
 EmailActivity.createIntent(this, "n_morioka")
 .setAction(Intent.ACTION_VIEW)
 })
 .build(); shortcutManager.setDynamicShortcuts(Arrays.asList(n_morioka)); .BJO"DUJWJUZKBWB
  20. %ZOBNJD4IPSUDVU .BJO"DUJWJUZ &NBJM"DUJWJUZ

  21. "OZRVFTUJPO