Slide 1

Slide 1 text

DeepLinkDispatch potatotips #19 Wasabeef

Slide 2

Slide 2 text

About Me wasabeef CyberAgent, Inc.

Slide 3

Slide 3 text

DeepLinkDispatch

Slide 4

Slide 4 text

Airbnb, Inc.

Slide 5

Slide 5 text

DeepLinkDispatch • Simple • Annotation-based API • and Simple

Slide 6

Slide 6 text

Usage

Slide 7

Slide 7 text

Gradle buildscript { dependencies { classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' } } apply plugin: 'com.neenbedankt.android-apt' dependencies { compile 'com.airbnb:deeplinkdispatch:1.2.+' apt 'com.airbnb:deeplinkdispatch-processor:1.2.+' }

Slide 8

Slide 8 text

AndroidManifest

Slide 9

Slide 9 text

Activity @DeepLinks({ “http://wasabeef.jp/deepLink/{id}”, “wasabeef://deepLink/{id}”, “wasabeef://anotherDeepLink” }) public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getIntent().getBooleanExtra(DeepLink.IS_DEEP_LINK, false)) { Bundle parameters = getIntent().getExtras(); String id = parameters.getString(id); // Do something with the ID... } ... } }

Slide 10

Slide 10 text

Method @DeepLink(“wasabeef://methodDeepLink/{param}”) public static Intent intentForDeepLinkMethod(Context context) { return new Intent(context, MainActivity.class) .setAction(ACTION_DEEP_LINK_METHOD); }

Slide 11

Slide 11 text

Callbacks public class SampleApplication extends Application implements DeepLinkCallback { private static final String TAG = DeepLinkDispatch; @Override public void onSuccess(String uri) { Log.i(“TAG, Successful deep link:” + uri.toString()); } @Override public void onError(DeepLinkError error) { Intent intent = getPackageManager().getLaunchIntentForPackage(getPackageName()); ComponentName componentName = intent.getComponent(); Intent mainIntent = IntentCompat.makeRestartActivityTask(componentName); startActivity(mainIntent); } }

Slide 12

Slide 12 text

Test adb shell am start -W -a android.intent.action.VIEW \ -d "wasabeef://deepLink/deepLink"

Slide 13

Slide 13 text

Thanks.