Skip to content

Commit

Permalink
Basic MIME type recognition in ContentProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
TpmKranz authored and MrAdityaAlok committed Oct 23, 2022
1 parent eeba498 commit 5d8c85f
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 5d8c85f

Please sign in to comment.