我已经看到这个对话框在某些应用程序中选择/打开android上的文件,在我看来它是原生的.但我找不到在自己的应用程序中使用它的方法.所附截图的语言是德语,但我相信有人会认出它.
Screenshot of the file-dialog
解决方法:
您可以使用具有MIME类型* / *的意图ACTION_GET_CONTENT.
它将在onActivityResult()中返回URI
@OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_main); Intent intent = new Intent() .setType("*/*") .setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select a file"), 123); } @OverrIDe protected voID onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if(requestCode == 123 && resultCode == RESulT_OK) { Uri selectedfile = data.getData(); //The uri with the location of the file } }
总结 以上是内存溢出为你收集整理的如何使用原生的android文件 – 打开对话框?全部内容,希望文章能够帮你解决如何使用原生的android文件 – 打开对话框?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)