{"id":18384885,"url":"https://github.com/allegro/slinger","last_synced_at":"2025-04-06T23:32:59.085Z","repository":{"id":57742450,"uuid":"41158659","full_name":"allegro/slinger","owner":"allegro","description":"Slinger - deep linking library for Android","archived":false,"fork":false,"pushed_at":"2023-03-20T21:53:30.000Z","size":222,"stargazers_count":28,"open_issues_count":0,"forks_count":10,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-07T15:36:04.173Z","etag":null,"topics":["android","deep-links"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/allegro.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-08-21T13:56:40.000Z","updated_at":"2023-05-07T23:01:43.000Z","dependencies_parsed_at":"2024-01-07T06:49:49.153Z","dependency_job_id":"aefc1060-3778-484f-ab30-1d96244d2862","html_url":"https://github.com/allegro/slinger","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allegro%2Fslinger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allegro%2Fslinger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allegro%2Fslinger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allegro%2Fslinger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allegro","download_url":"https://codeload.github.com/allegro/slinger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223266664,"owners_count":17116494,"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":["android","deep-links"],"created_at":"2024-11-06T01:15:47.879Z","updated_at":"2024-11-06T01:15:48.784Z","avatar_url":"https://github.com/allegro.png","language":"Java","funding_links":[],"categories":["Libs","Utility"],"sub_categories":["\u003cA NAME=\"Utility\"\u003e\u003c/A\u003eUtility"],"readme":"Slinger - deep linking library for Android \n====================\n\n[![Build Status](https://travis-ci.org/allegro/slinger.svg)](https://travis-ci.org/allegro/slinger)\n\nSlinger is a small Android library for handling custom Uri which uses regular expression to\ncatch and route URLs which won’t be handled by normal [intent-filter](http://developer.android.com/guide/topics/manifest/data-element.html#path) mechanism.\n\nWith slinger it’s possible to provide deep links for quite complicated URLs.\n\n![Scheme of Slinger resolving Activities using regular expression](assets/slinger_resolving_mechanism.png)\n\n## How do I use it?\n\nDeclare Activity in your manifest with your own `IntentResolver` that will handle links within particular domain.\n\n```xml\n\u003cactivity\n  android:name=\"pl.allegro.android.slinger.SlingerActivity\"\n  android:excludeFromRecents=\"true\"\n  android:noHistory=\"true\"\n  android:theme=\"@style/android:Theme.NoDisplay\"\u003e\n  \u003cmeta-data\n    android:name=\"IntentResolver\"\n    android:value=\"com.my.appp.ExampleIntentResolver\"/\u003e\n    \u003cintent-filter android:label=\"@string/app_name\"\u003e\n      \u003caction android:name=\"android.intent.action.VIEW\"/\u003e\n      \u003ccategory android:name=\"android.intent.category.DEFAULT\"/\u003e\n      \u003ccategory android:name=\"android.intent.category.BROWSABLE\"/\u003e\n      \u003cdata\n        android:host=\"example.com\"\n        android:pathPattern=\"/.*\"\n        android:scheme=\"http\"/\u003e\n    \u003c/intent-filter\u003e\n\u003c/activity\u003e\n```\n\n`IntentResolver` is a class that redirects URLs to concrete Activities based on regular expressions.\n\n```java\n\n@Keep\npublic class ExampleIntentResolver extends IntentResolver {\n\n  private List\u003cRedirectRule\u003e rules;\n\n  public ExampleIntentResolver(Activity activity) {\n    super(activity);\n    rules = asList(getRedirectRuleForAboutActivity(activity));\n  }\n\n  private RedirectRule getRedirectRuleForAboutActivity(Activity activity) {\n    return RedirectRule.builder()\n                       .intent(new Intent(activity, MyConcreteActivityA.class))\n                       .pattern(\"http://example.com/abc\\\\\\\\.html\\\\\\\\?query=a.*\")\n                       .build();\n  }\n\n  @NonNull @Override public Iterable\u003cRedirectRule\u003e getRules() {\n    return rules;\n  }\n}\n```\n\nIn case when no redirect rule is matched `IntentResolver` will fallback to default Intent - `Uri` with `ACTION_VIEW`.\n\n## Customizing\n\n### Matching Activities\n\nIn order to provide other mechanism than regular expression matching you can override `resolveIntentToSling` in `IntentResolver`\n\n### Enriching Slinged Intents with Referrer and input URL\n\nSlinger enriches Intents with URL and [referrer](http://developer.android.com/reference/android/app/Activity.html#getReferrer()) by default.\nThis can be changed by overriding `enrichIntent` in `IntentResolver`\n\n```java\n@Keep\npublic class ExampleIntentResolver extends IntentResolver {\n\n  @NonNull\n  @Override\n  public Intent resolveIntentToSling(@NonNull Uri originatingUri) {\n    // implement own intent resolving strategy here\n    return super.resolveIntentToSling(originatingUri);\n  }\n  \n  @Override\n  public Intent enrichIntent(Activity parentActivity, Intent resolvedIntent, Uri originatingUri) {\n    // enrich resolved intent with custom data\n    return super.enrichIntent(parentActivity, resolvedIntent, originatingUri).putExtra(\"foo\",\"bar\");\n  }\n}\n```\n\n## Security considerations\n\nSlinger does not sanitize input in any way. So providing security for application is your responsibility.\n\n## License\n\n**slinger** is published under [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallegro%2Fslinger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallegro%2Fslinger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallegro%2Fslinger/lists"}