Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
private static final Pattern PATH_PATTERN_IMPLICIT = Pattern.compile("/exmaple_content/.*");
private static final Pattern PATH_PATTERN_DEEP = Pattern.compile("/.*");
private void processIntentFilter() {
Intent intent = getIntent();
Uri uri;
if (intent != null && (uri = intent.getData()) != null) {
String id = null;
Matcher implicit = PATH_PATTERN_IMPLICIT.matcher(uri.getPath());
Matcher deep = PATH_PATTERN_DEEP.matcher(uri.getPath());
if (implicit.matches()) {
id = uri.getPathSegments().get(1);
} else if (deep.matches()) {
id = uri.getPathSegments().get(0);
}
if (id != null && id.isEmpty()) {
updateContent(id); // TODO
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment