Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Practical Implementation of Up Navigation
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Keisuke Kobayashi
March 22, 2017
Programming
2k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Practical Implementation of Up Navigation
potatotips #38
Keisuke Kobayashi
March 22, 2017
More Decks by Keisuke Kobayashi
See All by Keisuke Kobayashi
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
120
AI 1st でエンタープライズ SaaS を立ち上げる / AI 1st Enterprise SaaS
kobakei
1
310
プロダクト開発をAI 1stに変革する〜SaaS is dead時代で生き残るために〜 / AI 1st Product Development
kobakei
0
3.1k
今日から始める依存性の注入 / First Time Dependency Injection
kobakei
26
7.8k
iOSアプリの技術的負債をどう返済したか / How to repay the technical debt of iOS app
kobakei
2
1k
iOSアプリ内で不正なSSL証明書を検知する / SSL Pinning for iOS apps
kobakei
34
12k
Kyashアプリ開発の現場
kobakei
4
3k
Review of Google I/O 2017 & Prepare for Google I/O 2018
kobakei
0
350
APIクライアントをCodableで置き換えた話
kobakei
0
1.7k
Other Decks in Programming
See All in Programming
AWS Step Functions 大規模並列の壁を越える / jaws-sonic-2026-niigata-step-functions
kasacchiful
PRO
1
480
Java 27新機能 / Java 27 new features
kishida
2
150
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
4.7k
GraphRAGのKnowledge Graphを 直接!見る/View-GraphRAG's-KnowledgeGraph-directly!
tyumugi1113
1
340
Webの地図
yosuke_furukawa
PRO
6
4.6k
setup-vp GitLab対応の裏側
naokihaba
0
110
Snowflakeで業務アプリを作ろう。 Snowflakeのアプリ機能解説&実践ガイド
ayumu_yamaguchi
1
280
選挙速報を多くのユーザーへ 届ける Live Activities 設計
hamayokokuririn
0
150
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
290
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
290
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
250
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
180
Featured
See All Featured
Un-Boring Meetings
codingconduct
0
420
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
The Language of Interfaces
destraynor
162
27k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.8k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
500
Six Lessons from altMBA
skipperchong
29
4.5k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
730
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
250
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
Product Roadmaps are Hard
iamctodd
55
13k
Transcript
Practical Implementation of Up Navigation Keisuke Kobayashi (@kobakei) potatotips #38
About me • Keisuke Kobayashi • Coubic Inc • GitHub,
Qiita: @kobakei • Twitter: @ksk_kbys • Android, Rails, React
Up Navigation?
Up Back
Back vs Up • Back • Navigate to previous screen
which may be other app • Up • Navigate to parent screen in same app
Example
EC app • Timeline > Detail • Timeline > Search
> Detail • Timeline > Detail > Detail • Recommendation, similar items, … • Deep link > Detail • Notification, Google search result, …
Navigation Flow 5JNFMJOF 4FBSDI %FUBJM (deep link)
Navigation Flow 5JNFMJOF 4FBSDI %FUBJM (deep link) From search
Navigation Flow 5JNFMJOF 4FBSDI %FUBJM (deep link) Otherwise From search
How to implement?
Just calling Activity#finish() ?
Calling Activity#finish() ? @Override public boolean onOptionsItemSelected(MenuItem item) { switch
(item.getItemId()) { case android.R.id.home: finish(); return true; } return super.onOptionsItemSelected(item); }
Calling Activity#finish() ? • May be OK in simple flow
• NG in Timeline > Detail > Detail flow • It opens previous Detail screen… • NG in deep link flow • It closes app…
OK, I will copy & paste from developer.android.com
developer.android.com @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) {
// Respond to the action bar's Up/Home button case android.R.id.home: NavUtils.navigateUpFromSameTask(this); return true; } return super.onOptionsItemSelected(item); }
Something wrong…
What is wrong? 1. Recreated parent activity • Scroll position,
bottom navigation etc 2. Always same parent activity regardless of where it comes from
What is wrong? 1. Recreated parent activity • Scroll position,
bottom navigation etc 2. Always same parent activity regardless of where it comes from
Avoid recreating parent @Override public boolean onOptionsItemSelected(MenuItem item) { switch
(item.getItemId()) { case android.R.id.home: Intent upIntent = NavUtils.getParentActivityIntent(this); upIntent.addFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(upIntent); finish(); return true; } return super.onOptionsItemSelected(item); }
What is wrong? 1. Recreated parent activity • Scroll position,
bottom navigation etc 2. Always same parent activity regardless of where it comes from
Set parent activity class to bundle extra // DetailActivity#createIntent public
static Intent createIntent( @NonNull Context context, @Nullable Class<? extends Activity> parentClass) { Intent intent = new Intent(context, DetailActivity.class); if (parentClass != null) { intent.putExtra(KEY_PARENT, parentClass.getName()); } return intent; }
Restore parent activity class from bundle extra // Parent activity
class private Class parentClass; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // … String parentClassName = getIntent().getStringExtra(KEY_PARENT); if (TextUtils.isEmpty(parentClassName)) { parentClass = MainActivity.class; } else { try { parentClass = Class.forName(parentClassName); } catch (ClassNotFoundException e) { Timber.e(e); } } }
Create up intent with parent activity class @Override public
boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: Intent upIntent = new Intent(getApplicationContext(), parentClass); upIntent.addFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(upIntent); finish(); return true; } return super.onOptionsItemSelected(item); }
Complete
Conclusion • Explained how to implement UP navigation in complex
flow • Key points • FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGE_TOP • Set parent class in bundle extra and use for Intent to parent activity
Appendix • ͪΐͬͱෳࡶͳUPϘλϯͷ࣮ in Qiita • http://qiita.com/kobakei/items/ ae1a6d2062f34d3f6771 • DroidKaigi
2017 app
Thanks!