Slide 1

Slide 1 text

AppLaunchChecker @magiepooh

Slide 2

Slide 2 text

About me @magiepooh @magie_pooh Takuma Fujita

Slide 3

Slide 3 text

Company AbemaTV, Inc. (Cyber Agent, Inc.)

Slide 4

Slide 4 text

AppLaunchChecker

Slide 5

Slide 5 text

?

Slide 6

Slide 6 text

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AppLaunchChecker.hasStartedFromLauncher(this); // => false }

Slide 7

Slide 7 text

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AppLaunchChecker.onActivityCreate(this); AppLaunchChecker.hasStartedFromLauncher(this); // => true }

Slide 8

Slide 8 text

public static boolean hasStartedFromLauncher(Context context) { return context.getSharedPreferences(SHARED_PREFS_NAME, 0) .getBoolean(KEY_STARTED_FROM_LAUNCHER, false); } public static void onActivityCreate(Activity activity) { final SharedPreferences sp = activity.getSharedPreferences(SHARED_PREFS_NAME, 0); if (sp.getBoolean(KEY_STARTED_FROM_LAUNCHER, false)) { return; } final Intent launchIntent = activity.getIntent(); if (launchIntent == null) { return; } if (Intent.ACTION_MAIN.equals(launchIntent.getAction()) && (launchIntent.hasCategory(Intent.CATEGORY_LAUNCHER) || launchIntent.hasCategory(IntentCompat.CATEGORY_LEANBACK_LAUNCHER))) { SharedPreferencesCompat.EditorCompat.getInstance().apply( sp.edit().putBoolean(KEY_STARTED_FROM_LAUNCHER, true)); } } AppLaunchChecker.java

Slide 9

Slide 9 text

public static boolean hasStartedFromLauncher(Context context) { return context.getSharedPreferences(SHARED_PREFS_NAME, 0) .getBoolean(KEY_STARTED_FROM_LAUNCHER, false); } public static void onActivityCreate(Activity activity) { final SharedPreferences sp = activity.getSharedPreferences(SHARED_PREFS_NAME, 0); if (sp.getBoolean(KEY_STARTED_FROM_LAUNCHER, false)) { return; } final Intent launchIntent = activity.getIntent(); if (launchIntent == null) { return; } if (Intent.ACTION_MAIN.equals(launchIntent.getAction()) && (launchIntent.hasCategory(Intent.CATEGORY_LAUNCHER) || launchIntent.hasCategory(IntentCompat.CATEGORY_LEANBACK_LAUNCHER))) { SharedPreferencesCompat.EditorCompat.getInstance().apply( sp.edit().putBoolean(KEY_STARTED_FROM_LAUNCHER, true)); } } AppLaunchChecker.java

Slide 10

Slide 10 text

• SharedPreferencesʹΠϯςϯτͷΞΫγϣϯ ͱ͔ΧςΰϦͱ͔ݟͯϥϯνϟʔ͔Βىಈ͠ ͔ͨΛॻ͖ࠐΜͰΔ͚ͩ • SharedPreferencesͷ஋ΛϦηοτ͢Δ΋ͷ͸ ༻ҙ͞Ε͍ͯͳ͍

Slide 11

Slide 11 text

• Πϯετʔϧ > Launcherىಈ // true • Πϯετʔϧ > DeepLink // false • Πϯετʔϧ > Launcherىಈ > DeepLink // true ݁࿦ɿ

Slide 12

Slide 12 text

݁࿦ɿ • Πϯετʔϧ > Launcherىಈ // true • Πϯετʔϧ > DeepLink // false • Πϯετʔϧ > Launcherىಈ > DeepLink // true աڈʹϢʔβ͕Ұ౓Ͱ΋Launcher͔Βىಈ͔ͨ͠Ͳ͏͔

Slide 13

Slide 13 text

݁࿦ɿ Ͳ͜Ͱ࢖͑Δ͔શ͘ Θ͔ΒΜɻ