Skip to content

Commit

Permalink
Added: Basic MIME type recognition in ContentProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
TpmKranz authored and fornwall committed Sep 27, 2024
1 parent 6c00f1f commit 245158c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/src/main/java/com/termux/app/TermuxOpenReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ public Cursor query(@NonNull Uri uri, String[] projection, String selection, Str

@Override
public String getType(@NonNull Uri uri) {
String path = uri.getLastPathSegment();
int extIndex = path.lastIndexOf('.') + 1;
if (extIndex > 0) {
MimeTypeMap mimeMap = MimeTypeMap.getSingleton();
String ext = path.substring(extIndex).toLowerCase();
return mimeMap.getMimeTypeFromExtension(ext);
}
return null;
}

Expand Down

0 comments on commit 245158c

Please sign in to comment.