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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Diego Velásquez
August 20, 2017
Programming
95
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
69
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
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
20
6.4k
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.2k
3Dシーンの圧縮
fadis
1
690
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
120
エージェンティックRAGにAWSで入門しよう!
har1101
8
1.4k
New "Type" system on PicoRuby
pocke
1
810
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
490
運用エージェントは "作る" から "育てる" へ - 記憶と自己進化の3層設計パターン / self-evolving-agents-three-layer-agent-design
gawa
12
3.6k
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
5
3.9k
Spec-Driven Development with AI-Agents: From High-Level Requirements to Working Software
antonarhipov
2
490
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
1
660
技術記事、AIに書かせるか、自分で書くか? 〜それでも私が自分の手で書く理由〜 / #QiitaConference
jnchito
2
1.3k
Featured
See All Featured
How to Talk to Developers About Accessibility
jct
2
230
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
360
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
380
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
1
170
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
200
The SEO Collaboration Effect
kristinabergwall1
1
480
The SEO identity crisis: Don't let AI make you average
varn
0
490
How to make the Groovebox
asonas
2
2.2k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
200
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
310
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]