Mobile Development 18 min read

Design and Implementation of External Deep Linking (Return Flow) for Android Applications

The article presents a unified external deep‑linking (return flow) architecture for Android apps that consolidates all entry points into a single ActionActivity, standardizes URLs, employs a configurable protocol dispatcher, uses a chain‑of‑responsibility checker system with interruption recovery via CheckerActivity, thereby decoupling routing logic, eliminating duplication, and scaling complex navigation scenarios.

Sohu Tech Products
Sohu Tech Products
Sohu Tech Products
Design and Implementation of External Deep Linking (Return Flow) for Android Applications

This article discusses the design and implementation of a unified external deep linking (回流) solution for complex Android applications. The solution addresses four key challenges: unifying all return flow entry points, establishing a reusable routing protocol, supporting conditional checks with recovery mechanisms, and integrating reuse design with interruption recovery.

The approach uses ActionActivity as a single entry point to handle various external sources including Launcher, Push notifications, external H5 pages, third-party apps via ShareSDK, and system share components. All entry points are converted to a standardized URL scheme format (sohuhy://host/path?params) for consistent processing.

The protocol design follows standard URL format with internal conventions for scheme, host, path, and parameters. Different protocols like mainPage, browser, and shareToNative are mapped to specific dispatcher classes using a ProtocolConfig configuration class. The ProtocolExecutor uses reflection to instantiate the appropriate handler and populate its fields from the protocol parameters.

For conditional checks (login required, upgrade required, new user guide, etc.), a Chain of Responsibility pattern is implemented through inheritance. Each Checker class (LoginChecker, UpgradeChecker, NewUserGuideChecker, etc.) extends BaseChecker and either proceeds to the next check via super.dispatch() or interrupts the flow by launching the appropriate activity.

The interruption recovery mechanism uses CheckerActivity as a base class that stores the current checkpoint. When the interrupted operation completes, restoreChecker() is called to resume the flow from where it was interrupted. The BaseChecker also stores the protocol URI, allowing seamless continuation to the target page after all conditions are satisfied.

This architecture successfully decouples entry points from business logic, reduces code duplication, and provides a scalable solution for handling complex routing scenarios in mobile applications.

chain of responsibilitydesign patternsAndroid Developmentdeep linkingURL schememobile architectureApp RoutingProtocol Dispatcher
Sohu Tech Products
Written by

Sohu Tech Products

A knowledge-sharing platform for Sohu's technology products. As a leading Chinese internet brand with media, video, search, and gaming services and over 700 million users, Sohu continuously drives tech innovation and practice. We’ll share practical insights and tech news here.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.