{"id":21161130,"url":"https://github.com/clayallsopp/routable-android","last_synced_at":"2025-04-06T03:11:12.875Z","repository":{"id":7446913,"uuid":"8788934","full_name":"clayallsopp/routable-android","owner":"clayallsopp","description":"Routable, an in-app native URL router, for Android","archived":false,"fork":false,"pushed_at":"2015-08-18T07:06:47.000Z","size":407,"stargazers_count":475,"open_issues_count":6,"forks_count":65,"subscribers_count":34,"default_branch":"master","last_synced_at":"2024-05-22T04:29:05.048Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clayallsopp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-03-15T00:56:45.000Z","updated_at":"2024-01-15T00:35:40.000Z","dependencies_parsed_at":"2022-09-10T03:13:17.773Z","dependency_job_id":null,"html_url":"https://github.com/clayallsopp/routable-android","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clayallsopp%2Froutable-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clayallsopp%2Froutable-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clayallsopp%2Froutable-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clayallsopp%2Froutable-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clayallsopp","download_url":"https://codeload.github.com/clayallsopp/routable-android/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247427006,"owners_count":20937201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T13:08:23.700Z","updated_at":"2025-04-06T03:11:12.847Z","avatar_url":"https://github.com/clayallsopp.png","language":"Java","funding_links":[],"categories":["Libs"],"sub_categories":["\u003cA NAME=\"Utility\"\u003e\u003c/A\u003eUtility"],"readme":"# Routable\n\nRoutable is an in-app native URL router, for Android. Also available for [iOS](https://github.com/usepropeller/routable-ios).\n\n## Usage\n\nSet up your app's router and URLs:\n\n```java\nimport com.usepropeller.routable.Router;\n\npublic class PropellerApplication extends Application {\n    @Override\n    public void onCreate() {\n        super.onCreate();\n        \n        // Set the global context\n        Router.sharedRouter().setContext(getApplicationContext());\n        // Symbol-esque params are passed as intent extras to the activities\n        Router.sharedRouter().map(\"users/:id\", UserActivity.class);\n        Router.sharedRouter().map(\"users/new/:name/:zip\", NewUserActivity.class);\n    }\n}\n```\n\nIn your `Activity` classes, add support for the URL params:\n\n```java\nimport com.usepropeller.routable.Router;\n\npublic class UserActivity extends Activity {\n    @Override\n    public void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n\n        Bundle intentExtras = getIntent().getExtras();\n        // Note this extra, and how it corresponds to the \":id\" above\n        String userId = intentExtras.get(\"id\");\n    }\n}\n\npublic class NewUserActivity extends Activity {\n    @Override\n    public void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n\n        Bundle intentExtras = getIntent().getExtras();\n        // Corresponds to the \":name\" above\n        String name = intentExtras.get(\"name\");\n        // Corresponds to the \":zip\" above\n        String zip = intentExtras.get(\"zip\");\n    }\n}\n```\n\n*Anywhere* else in your app, open some URLs:\n\n```java\n// starts a new UserActivity\nRouter.sharedRouter().open(\"users/16\");\n// starts a new NewUserActivity\nRouter.sharedRouter().open(\"users/new/Clay/94303\");\n```\n\n## Installation\n\nRoutable is currently an Android library project (so no Maven).\n\nIf you're in a hurry, you can just copy-paste the [Router.java](https://github.com/usepropeller/routable-android/blob/master/src/com/usepropeller/routable/Router.java) file.\n\nOr if you're being a little more proactive, you should import the Routable project (this entire git repo) into Eclipse and [reference it](http://developer.android.com/tools/projects/projects-eclipse.html#ReferencingLibraryProject) in your own project. \n\n## Features\n\n### Routable Functions\n\nYou can call arbitrary blocks of code with Routable:\n\n```java\nRouter.sharedRouter().map(\"logout\", new Router.RouterCallback() {\n    public void run(Router.RouteContext context) {\n        User.logout();\n    }\n});\n\n// Somewhere else\nRouter.sharedRouter().open(\"logout\");\n```\n\n### Open External URLs\n\nSometimes you want to open a URL outside of your app, like a YouTube URL or open a web URL in the browser. You can use Routable to do that:\n\n```java\nRouter.sharedRouter().openExternal(\"http://www.youtube.com/watch?v=oHg5SJYRHA0\")\n```\n\n### Multiple Routers\n\nIf you need to use multiple routers, simply create new instances of `Router`:\n\n```java\nRouter adminRouter = new Router();\n\nRouter userRouter = new Router();\n```\n\n## Contact\n\nClay Allsopp ([http://clayallsopp.com](http://clayallsopp.com))\n\n- [http://twitter.com/clayallsopp](http://twitter.com/clayallsopp)\n- [clay@usepropeller.com](clay@usepropeller.com)\n\n## License\n\nRoutable for Android is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclayallsopp%2Froutable-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclayallsopp%2Froutable-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclayallsopp%2Froutable-android/lists"}