2024年Android最全Android 选择文件返回路径怎么就这么难?,2024年最新android程序员面试笔试宝典 pdf

建议

当我们出去找工作,或者准备找工作的时候,我们一定要想,我面试的目标是什么,我自己的技术栈有哪些,近期能掌握的有哪些,我的哪些短板 ,列出来,有计划的去完成,别看前两天掘金一些大佬在驳来驳去 ,他们的观点是他们的,不要因为他们的观点,膨胀了自己,影响自己的学习节奏。基础很大程度决定你自己技术层次的厚度,你再熟练框架也好,也会比你便宜的,性价比高的替代,很现实的问题但也要有危机意识,当我们年级大了,有哪些亮点,与比我们经历更旺盛的年轻小工程师,竞争。

  • 无论你现在水平怎么样一定要 持续学习 没有鸡汤,别人看起来的毫不费力,其实费了很大力,这四个字就是我的建议!!!!!!!!!

  • 准备想说怎么样写简历,想象算了,我觉得,技术就是你最好的简历

  • 我希望每一个努力生活的it工程师,都会得到自己想要的,因为我们很辛苦,我们应得的。

  • 有什么问题想交流,欢迎给我私信,欢迎评论

【附】相关架构及资料

Android高级技术大纲

面试资料整理

内含往期Android高级架构资料、源码、笔记、视频。高级UI、性能优化、架构师课程、NDK、混合式开发(ReactNative+Weex)微信小程序、Flutter全方面的Android进阶实践技术

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

// DownloadsProvider

else if (isDownloadsDocument(uri)) {

final String id = DocumentsContract.getDocumentId(uri);

if (id != null && id.startsWith(“raw:”)) {

return id.substring(4);

}

String[] contentUriPrefixesToTry = new String[]{

“content://downloads/public_downloads”,

“content://downloads/my_downloads”

};

for (String contentUriPrefix : contentUriPrefixesToTry) {

try {

// note: id 可能为字符串,如在华为10.0系统上,选择文件后id为:“msf:254”,导致转Long异常

Uri contentUri = ContentUris.withAppendedId(Uri.parse(contentUriPrefix), Long.parseLong(id));

String path = getDataColumn(context, contentUri, null, null);

if (path != null && !path.equals(“”)) {

return path;

}

} catch (Exception e) {

}

}

// path could not be retrieved using ContentResolver, therefore copy file to accessible cache using streams

String fileName = getFileName(context, uri);

File cacheDir = getDocumentCacheDir(context);

File file = generateFileName(fileName, cacheDir);

String destinationPath = null;

if (file != null) {

destinationPath = file.getAbsolutePath();

saveFileFromUri(context, uri, destinationPath);

}

return destinationPath;

}

// MediaProvider

else if (isMediaDocument(uri)) {

final String docId = DocumentsContract.getDocumentId(uri);

final String[] split = docId.split(“:”);

final String type = split[0];

Uri contentUri = null;

if (“image”.equals(type)) {

contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;

} else if (“video”.equals(type)) {

contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;

} else if (“audio”.equals(type)) {

contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;

}

final String selection = “_id=?”;

final String[] selectionArgs = new String[]{split[1]};

return getDataColumn(context, contentUri, selection, selectionArgs);

}

}

// MediaStore (and general)

else if (“content”.equalsIgnoreCase(uri.getScheme())) {

String path = getDataColumn(context, uri, null, null);

if (path != null && !path.equals(“”)) return path;

// path could not be retrieved using ContentResolver, therefore copy file to accessible cache using streams

String fileName = getFileName(context, uri);

File cacheDir = getDocumentCacheDir(context);

File file = generateFileName(fileName, cacheDir);

String destinationPath = null;

if (file != null) {

destinationPath = file.getAbsolutePath();

saveFileFromUri(context, uri, destinationPath);

}

return destinationPath;

}

// File

else if (“file”.equalsIgnoreCase(uri.getScheme())) {

return uri.getPath();

}

return null;

}

/**

  • @param uri The Uri to check.

  • @return Whether the Uri authority is ExternalStorageProvider.

*/

public static boolean isExternalStorageDocument(Uri uri) {

return “com.android.externalstorage.documents”.equals(uri.getAuthority());

}

/**

  • @param uri The Uri to check.

  • @return Whether the Uri authority is DownloadsProvider.

*/

public static boolean isDownloadsDocument(Uri uri) {

return “com.android.providers.downloads.documents”.equals(uri.getAuthority());

}

/**

  • @param uri The Uri to check.

  • @return Whether the Uri authority is MediaProvider.

*/

public static boolean isMediaDocument(Uri uri) {

return “com.android.providers.media.documents”.equals(uri.getAuthority());

}

public static String getDataColumn(Context context, Uri uri, String selection,

String[] selectionArgs) {

Cursor cursor = null;

final String column = “_data”;

final String[] projection = {column};

String path = “”;

try {

cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,

null);

if (cursor != null && cursor.moveToFirst()) {

final int column_index = cursor.getColumnIndexOrThrow(column);

path = cursor.getString(column_index);

return path;

}

} catch (Exception e) {

e.printStackTrace();

} finally {

if (cursor != null)

cursor.close();

}

return path;

}

public static String getFileName(@NonNull Context context, Uri uri) {

String mimeType = context.getContentResolver().getType(uri);

String filename = null;

if (mimeType == null && context != null) {

String path = getPath(context, uri);

if (path == null) {

filename = getName(uri.toString());

} else {

File file = new File(path);

filename = file.getName();

}

} else {

Cursor returnCursor = context.getContentResolver().query(uri, null,

null, null, null);

if (returnCursor != null) {

int nameIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);

returnCursor.moveToFirst();

filename = returnCursor.getString(nameIndex);

returnCursor.close();

}

}

return filename;

}

public static String getName(String filename) {

if (filename == null) {

return null;

}

int index = filename.lastIndexOf(‘/’);

return filename.substring(index + 1);

}

public static File getDocumentCacheDir(@NonNull Context context) {

Log.d(“PickUtils”, “getDocumentCacheDir”);

File dir = new File(context.getCacheDir(), DOCUMENTS_DIR);

if (!dir.exists()) {

dir.mkdirs();

}

return dir;

}

@Nullable

public static File generateFileName(@Nullable String name, File directory) {

if (name == null) {

return null;

}

File file = new File(directory, name);

if (file.exists()) {

String fileName = name;

String extension = “”;

int dotIndex = name.lastIndexOf(‘.’);

if (dotIndex > 0) {

fileName = name.substring(0, dotIndex);

extension = name.substring(dotIndex);

}

int index = 0;

while (file.exists()) {

index++;

name = fileName + ‘(’ + index + ‘)’ + extension;

file = new File(directory, name);

}

}

try {

if (!file.createNewFile()) {

return null;

}

} catch (IOException e) {

return null;

}

return file;

}

private static void saveFileFromUri(Context context, Uri uri, String destinationPath) {

InputStream is = null;

BufferedOutputStream bos = null;

try {

is = context.getContentResolver().openInputStream(uri);

bos = new BufferedOutputStream(new FileOutputStream(destinationPath, false));

byte[] buf = new byte[1024];

is.read(buf);

do {

bos.write(buf);

} while (is.read(buf) != -1);

} catch (IOException e) {

e.printStackTrace();

} finally {

try {

if (is != null) is.close();

if (bos != null) bos.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}

}

5. 类型对应


private final String[][] MIME_MapTable={

//{后缀名,MIME类型}

{“.3gp”, “video/3gpp”},

{“.apk”, “application/vnd.android.package-archive”},

{“.asf”, “video/x-ms-asf”},

{“.avi”, “video/x-msvideo”},

{“.bin”, “application/octet-stream”},

{“.bmp”, “image/bmp”},

{“.c”, “text/plain”},

{“.class”, “application/octet-stream”},

{“.conf”, “text/plain”},

{“.cpp”, “text/plain”},

{“.doc”, “application/msword”},

{“.docx”, “application/vnd.openxmlformats-officedocument.wordprocessingml.document”},

{“.xls”, “application/vnd.ms-excel”},

{“.xlsx”, “application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”},

{“.exe”, “application/octet-stream”},

{“.gif”, “image/gif”},

{“.gtar”, “application/x-gtar”},

{“.gz”, “application/x-gzip”},

{“.h”, “text/plain”},

{“.htm”, “text/html”},

{“.html”, “text/html”},

{“.jar”, “application/java-archive”},

{“.java”, “text/plain”},

{“.jpeg”, “image/jpeg”},

{“.jpg”, “image/jpeg”},

{“.js”, “application/x-javascript”},

{“.log”, “text/plain”},

{“.m3u”, “audio/x-mpegurl”},

{“.m4a”, “audio/mp4a-latm”},

{“.m4b”, “audio/mp4a-latm”},

{“.m4p”, “audio/mp4a-latm”},

{“.m4u”, “video/vnd.mpegurl”},

{“.m4v”, “video/x-m4v”},

{“.mov”, “video/quicktime”},

{“.mp2”, “audio/x-mpeg”},

{“.mp3”, “audio/x-mpeg”},

{“.mp4”, “video/mp4”},

{“.mpc”, “application/vnd.mpohun.certificate”},

{“.mpe”, “video/mpeg”},

{“.mpeg”, “video/mpeg”},

{“.mpg”, “video/mpeg”},

{“.mpg4”, “video/mp4”},

{“.mpga”, “audio/mpeg”},

{“.msg”, “application/vnd.ms-outlook”},

{“.ogg”, “audio/ogg”},

{“.pdf”, “application/pdf”},

结尾

最后小编想说:不论以后选择什么方向发展,目前重要的是把Android方面的技术学好,毕竟其实对于程序员来说,要学习的知识内容、技术有太多太多,要想不被环境淘汰就只有不断提升自己,从来都是我们去适应环境,而不是环境来适应我们!

当程序员容易,当一个优秀的程序员是需要不断学习的,从初级程序员到高级程序员,从初级架构师到资深架构师,或者走向管理,从技术经理到技术总监,每个阶段都需要掌握不同的能力。早早确定自己的职业方向,才能在工作和能力提升中甩开同龄人。

想要拿高薪实现技术提升薪水得到质的飞跃。最快捷的方式,就是有人可以带着你一起分析,这样学习起来最为高效,所以为了大家能够顺利进阶中高级、架构师,我特地为大家准备了一套高手学习的源码和框架视频等精品Android架构师教程,保证你学了以后保证薪资上升一个台阶。

当你有了学习线路,学习哪些内容,也知道以后的路怎么走了,理论看多了总要实践的。

高级UI,自定义View

UI这块知识是现今使用者最多的。当年火爆一时的Android入门培训,学会这小块知识就能随便找到不错的工作了。

不过很显然现在远远不够了,拒绝无休止的CV,亲自去项目实战,读源码,研究原理吧!

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

秀的程序员是需要不断学习的,从初级程序员到高级程序员,从初级架构师到资深架构师,或者走向管理,从技术经理到技术总监,每个阶段都需要掌握不同的能力。早早确定自己的职业方向,才能在工作和能力提升中甩开同龄人。

想要拿高薪实现技术提升薪水得到质的飞跃。最快捷的方式,就是有人可以带着你一起分析,这样学习起来最为高效,所以为了大家能够顺利进阶中高级、架构师,我特地为大家准备了一套高手学习的源码和框架视频等精品Android架构师教程,保证你学了以后保证薪资上升一个台阶。

当你有了学习线路,学习哪些内容,也知道以后的路怎么走了,理论看多了总要实践的。

[外链图片转存中…(img-UiptQSPF-1715608610189)]

高级UI,自定义View

UI这块知识是现今使用者最多的。当年火爆一时的Android入门培训,学会这小块知识就能随便找到不错的工作了。

不过很显然现在远远不够了,拒绝无休止的CV,亲自去项目实战,读源码,研究原理吧!

[外链图片转存中…(img-XHiQr0Sn-1715608610189)]

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

  • 14
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值