Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Android Intents using Dart & Henson
Search
Diego Velásquez
August 20, 2017
Programming
96
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Android Intents using Dart & Henson
Diego Velásquez
August 20, 2017
More Decks by Diego Velásquez
See All by Diego Velásquez
Flutter: Don't be afraid, State Management is your friend
diegoveloper
2
76
Stateful & Async Widgets
diegoveloper
0
110
Bienvenido a Flutter
diegoveloper
0
66
Beautiful apps in record time with Flutter
diegoveloper
0
57
Hello Flutter - Beautiful apps in record time
diegoveloper
0
140
Introducción a Flutter
diegoveloper
1
200
Flutter y el impacto en el mercado actual de apps móviles
diegoveloper
0
140
Let's start with Flutter
diegoveloper
0
81
Hello Flutter!
diegoveloper
0
160
Other Decks in Programming
See All in Programming
php-fpmのプロセスが枯渇した日-調査・対処・そして本当にやるべきだったこと-
shibuchaaaan
0
320
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
210
AI時代に設計が 最大の生産性レバーになる 意図駆動開発とデータを消さない設計|Don't Delete Your Data or Your Intent — Design as the Deepest Lever in the AI Era
tomohisa
1
1.1k
5分で問診!Composer セキュリティ健康診断
codmoninc
0
1.1k
170k Jobs a Day on GKE: Scaling Mercari's CI Platform - and What's Next for AI-Native Development
junyaokabe
0
110
TSX の <Hoge<Fuga>> という構文に驚いた話 / tsx-type-argument-syntax
kanaru0928
0
230
yield再入門 #phpcon
o0h
PRO
0
1.2k
S3 を使うアプリケーションをローカル完結で動かすことに全力を注いでみた / Running S3 Apps Offline
contour_gara
0
540
What's New in Android 2026
veronikapj
0
270
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
220
Webエンジニアなのにブラウザの仕組みがわからないので、Pythonで自作してみた
tatsuki12
0
120
Claude Code全社展開のためにやったことn選~プラグイン302個・コミッター271人を支えるために~
kenchan
5
1.6k
Featured
See All Featured
Utilizing Notion as your number one productivity tool
mfonobong
4
550
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.3k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
57k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Producing Creativity
orderedlist
PRO
348
40k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
250
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
Amusing Abliteration
ianozsvald
1
250
Mobile First: as difficult as doing things right
swwweet
225
10k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
So, you think you're a good person
axbom
PRO
2
2.1k
Rails Girls Zürich Keynote
gr2m
96
14k
Transcript
Android Intents with Dart & Henson Diego Velasquez Android Developer
Belatrix SF @diegoveloper
Intents An intent is an abstract description of an operation
to be performed. Activity Broadcast Receiver Service Intent
Have not specified a component; instead declare a general action
to perform, which allows a component from another app to handle it Intent types Have specified a component which provides the exact class to be run. Implicit Explicit
Intent intent = new Intent( this, DetailActivity.class); startActivity(intent); Explicit Intent
MainActivity.class DetailActivity.class
Creating & Consuming Intents public static final String INTENT_PARAM =
"param_name"; ... Intent intent = new Intent( this, DetailActivity.class); intent.putExtra(INTENT_PARAM, "Android"); startActivity(intent); public static final String INTENT_PARAM = "param_name"; ... Intent intent = getIntent(); if (intent != null && intent.hasExtra(INTENT_PARAM)){ String name = getIntent().getStringExtra(INTENT_PARAM); }
What do we do? public static void startDetailActivity(Context context, String
param1, String param2){ Intent intent = new Intent(context, DetailActivity.class); intent.putExtra("PARAM_1", param1); intent.putExtra("PARAM_2",param2); context.startActivity(intent); } public static void startDetailActivity(Context context, String param1){ Intent intent = new Intent(context, DetailActivity.class); intent.putExtra("PARAM_1", param1); context.startActivity(intent); } public static void startDetailActivity(Context context, String param1, String param2){ Intent intent = new Intent(context, DetailActivity.class); if (param1 != null) intent.putExtra("PARAM_1", param1); if (param2 != null) intent.putExtra("PARAM_2",param2); context.startActivity(intent); } public static void startDetailActivity(Context context, String param1){ startDetailActivity(context, param1,null); } Refactoring
Dart & Henson Android dependency Injection library to deal with
Intent data passing
Dart: Consuming Intents DetailActivity.java @InjectExtra String paramName; … @Override protected
void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); Dart.inject(this); }
Dart: Features @InjectExtra String paramName; @InjectExtra User user; @InjectExtra("quantity") int
quantityValue; @InjectExtra boolean isSuccess = false; @Nullable @InjectExtra String anotherValue; public class DetailModel { @InjectExtra String valueModel; public String getValueModel() { return valueModel; } } DetailActivity.java DetailModel model = new DetailModel(); …. @Override protected void onCreate(Bundle savedInstanceState) { …. Dart.inject(model,this); String ourValue = model.getValueModel(); }
Dart: Set Up build.gradle compile 'com.f2prateek.dart:dart:2.0.2' provided 'com.f2prateek.dart:dart-processor:2.0.2'
Henson: Creating Intents @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); Intent intent = Henson.with(this).gotoDetailActivity().paramName("Test value").build(); startActivity(intent); }
Henson: Features Intent intent = Henson.with(this).gotoDetailActivity() .isSuccess(true) .paramName("Test") .quantity(5) .user(new
User()) .build(); startActivity(intent); @HensonNavigable(model = DetailModel.class) public class DetailActivity extends AppCompatActivity { DetailModel model = new DetailModel(); …. @Override protected void onCreate(Bundle savedInstanceState) { …. Dart.inject(model,this); } Intent intent = Henson.with(this).goToDetailActivity().valueModel("testing").build(); startActivity(intent);
Henson: Set Up build.gradle compile 'com.f2prateek.dart:henson:2.0.2' provided 'com.f2prateek.dart:henson-processor:2.0.2'
Place your screenshot here Let’s code
References ▪ Intents: https://developer.android.com/guide/components/intents-filters.html ▪ Dart & Henson: https://github.com/f2prateek/dart
Thanks! Any questions? You can find me at ▪ https://github.com/diegoveloper
▪
[email protected]