Skip to content

Commit c5f000a

Browse files
TpmKranzagnostic-apollo
authored andcommitted
Added: Basic MIME type recognition in ContentProvider
1 parent c154407 commit c5f000a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

app/src/main/java/com/termux/app/TermuxOpenReceiver.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ public Cursor query(@NonNull Uri uri, String[] projection, String selection, Str
161161

162162
@Override
163163
public String getType(@NonNull Uri uri) {
164+
String path = uri.getLastPathSegment();
165+
int extIndex = path.lastIndexOf('.') + 1;
166+
if (extIndex > 0) {
167+
MimeTypeMap mimeMap = MimeTypeMap.getSingleton();
168+
String ext = path.substring(extIndex).toLowerCase();
169+
return mimeMap.getMimeTypeFromExtension(ext);
170+
}
164171
return null;
165172
}
166173

0 commit comments

Comments
 (0)