android打开指定文件
⑴ 安卓系统里如何更改打开某个文件的默认打开方式
打开设置,应用程序,找到要改的软件,点击,往下拉,清除默认设置,或者清除默认值,以后打开这种文件需要选择打开方式。操作非常简单,不再附图说明啦。
文件管理器是一个类Windows的文件管理器,打开后会有一种很熟悉的感觉。可以让你的手机瞬间成为电脑,这款文件管理软件,对于文件的管理风格非常采用了电脑文件的管理风格,界面更加的直观,对于大多数人来说,这款软件的操作更加的便利,更容易操作使用。功能也很丰富,可以直接查看图片等,设置这款软件拥有3D视图功能。
⑵ Android如何触发intent打开指定目录
Android触发intent打开指定目录的步骤:
1、android系统内置了很多应用,包括电话拨号,短信,浏览器等,这里创建一个简单的Android程序,调用内置的浏览器打开指定的地址。
2、对应的layout xml为:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/btnGo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="46dp"
android:text="@string/btnTitle_go" />
<EditText
android:id="@+id/txtUri"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btnGo"
android:layout_alignBottom="@+id/btnGo"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/btnGo"
android:ems="10"
android:text="http://junqilian.cnblogs.com" >
<requestFocus />
</EditText>
</RelativeLayout>
3、java代码实现如下,主要是给EditText添加一个OnKeyListener,处理在editText里面按回车键,给button添加一个onClickListener,触发到OpenBroswer函数,通过intent打开内置的浏览器。
⑶ android开发 怎么实现点击按钮打开文件浏览器并自动定位到指定文件夹
文件浏览器就是常见的文件管理app对吧?关键不在定位path,我认为(特别强调,我认为),解决方案,
1,拥有文件管理app源码,修改或者了解是否 支持其他应用的参照启动方式,就是非launcher启动时,是否能处理path或uri参数。
2,在你的app中附加,文件浏览(功能)。
⑷ android如何打开一个文件使用安装应用程序吗
应用中如何调用系统所装的软件打开一个文件,这是我们经常碰到的问题,下面是我所用到的一种方法,和大家一起分享一下!
这个是打开文件的一个方法:
Java代码
/**
*打开文件
*@paramfile
*/
privatevoidopenFile(Filefile){
Intentintent=newIntent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//设置intent的Action属性
intent.setAction(Intent.ACTION_VIEW);
//获取文件file的MIME类型
Stringtype=getMIMEType(file);
//设置intent的data和Type属性。
intent.setDataAndType(/*uri*/Uri.fromFile(file),type);
//跳转
startActivity(intent);
}
/**
*根据文件后缀名获得对应的MIME类型。
*@paramfile
*/
privateStringgetMIMEType(Filefile){
Stringtype="*/*";
StringfName=file.getName();
//获取后缀名前的分隔符"."在fName中的位置。
intdotIndex=fName.lastIndexOf(".");
if(dotIndex<0){
returntype;
}
/*获取文件的后缀名*/
Stringend=fName.substring(dotIndex,fName.length()).toLowerCase();
if(end=="")returntype;
//在MIME和文件类型的匹配表中找到对应的MIME类型。
for(inti=0;i<MIME_MapTable.length;i++){//MIME_MapTable??在这里你一定有疑问,这个MIME_MapTable是什么?
if(end.equals(MIME_MapTable[i][0]))
type=MIME_MapTable[i][1];
}
returntype;
}
privatefinalString[][]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"},
{".png","image/png"},
{".pps","application/vnd.ms-powerpoint"},
{".ppt","application/vnd.ms-powerpoint"},
{".pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"},
{".prop","text/plain"},
{".rc","text/plain"},
{".rmvb","audio/x-pn-realaudio"},
{".rtf","application/rtf"},
{".sh","text/plain"},
{".tar","application/x-tar"},
{".tgz","application/x-compressed"},
{".txt","text/plain"},
{".wav","audio/x-wav"},
{".wma","audio/x-ms-wma"},
{".wmv","audio/x-ms-wmv"},
{".wps","application/vnd.ms-works"},
{".xml","text/plain"},
{".z","application/x-compress"},
{".zip","application/x-zip-compressed"},
{"","*/*"}
};
MIME_MapTable是所有文件的后缀名所对应的MIME类型的一个String数组:
Java代码
⑸ Android开发怎么打开指定文件夹
网页链接 希望对你有所帮助
⑹ 如何写android指定文件路径
Android根据路径打开文件夹的步骤:
1、android系统内置了很多应用,包括电话拨号,短信,浏览器等,这里创建一个简单的Android程序,调用内置的浏览器打开指定的地址。
2、对应的layout xml为:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/btnGo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="46dp"
android:text="@string/btnTitle_go" />
<EditText
android:id="@+id/txtUri"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btnGo"
android:layout_alignBottom="@+id/btnGo"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/btnGo"
android:ems="10"
android:text="http://junqilian.cnblogs.com" >
<requestFocus />
</EditText>
</RelativeLayout>
3、Java代码实现如下,主要是给EditText添加一个OnKeyListener,处理在editText里面按回车键,给button添加一个onClickListener,触发到OpenBroswer函数,通过intent打开内置的浏览器。
⑺ 怎样更改安卓手机的文件打开方式,也就是用什么app打开某一类型的文件
1、打开自己的手机资源管理器,然后打开其中某一个类型的文件,将会弹出设置窗。
安卓系统的打开方式是由应用程序注册的,例如像UC这些浏览器会注册URL的打开方式。像天天动听这些播放器会注册MP3的打开方式。
拓展资料:
当碰到多个文件都注册一个时,就会出现应用程序的选择框让用户来选择一个适合的来打开。例如你安装了UC和海豚浏览器,那么打开短信的网址时会同时出现默认的谷歌浏览器、UC和海豚让你从3个中选择一个,你还可以选择一个为默认。
那选择了默认以后,想用其它的也注册该文件的工具打开呢?解决办法很简单,进入设置--应用程序,找到你设置为默认的那个应用程序,点击"清除默认设置"即可。
⑻ android如何读取指定目录的文件
这个还要看你是什么文件,举个例子获取图片文件。
Bitmap bitmap = BitmapFactory.decodeFile(android.os.Environment.getExternalStorageDirectory().getAbsolutePath()+ "/data/abc/def/ghi.jkl")
⑼ 安卓开发怎么在APP内部调用手机系统浏览器打开指定html并获取HTML的数据
Android开发_如何调用 浏览器访问网页和Html文件
一、启动android默认浏览器
Intent intent= new Intent();
intent.setAction('android.intent.action.VIEW');
Uri content_url = Uri.parse('http://www.cnblogs.com');
intent.setData(content_url);
startActivity(intent);
这样子,android就可以调用起手机默认的浏览器访问。
二、指定相应的浏览器访问
1、指定android自带的浏览器访问
( “com.android.browser”:packagename ;“com.android.browser.BrowserActivity”:启动主activity)
Intent intent= new Intent();
intent.setAction('android.intent.action.VIEW');
Uri content_url = Uri.parse('http://www.cnblogs.com');
intent.setData(content_url);
intent.setClassName('com.android.browser','com.android.browser.BrowserActivity');
startActivity(intent);
2、启动其他浏览器(当然该浏览器必须安装在机器上)
只要修改以下相应的packagename 和 主启动activity即可调用其他浏览器
intent.setClassName('com.android.browser','com.android.browser.BrowserActivity');
uc浏览器':'com.uc.browser', 'com.uc.browser.ActivityUpdate“
opera :'com.opera.mini.android', 'com.opera.mini.android.Browser'
qq浏览器:'com.tencent.mtt', 'com.tencent.mtt.MainActivity'
三、打开本地html文件
打开本地的html文件的时候,一定要指定某个浏览器,而不能采用方式一来浏览,具体示例代码如下
Intent intent= new Intent();
intent.setAction('android.intent.action.VIEW');
Uri content_url = Uri.parse('content://com.android.htmlfileprovider/sdcard/help.html');
intent.setData(content_url);
intent.setClassName('com.android.browser','com.android.browser.BrowserActivity');
startActivity(intent);
关键点是调用了”content“这个filter。
以前有在win32编程的朋友,可能会觉得用这种形式”file://sccard/help.html“是否可以,可以很肯定的跟你说,默认的浏览器设置是没有对”file“这个进行解析的,如果要让你的默认android浏览器有这个功能需要自己到android源码修改manifest.xml文件,然后自己编译浏览器代码生成相应的apk包来重新在机器上安装。
大体的步骤如下:
1、打开 packages/apps/Browser/AndroidManifest.xml文件把加到相应的后面就可以了
2、重新编译打包,安装,这样子,新的浏览器就支持”file“这个形式了
有兴趣的可以去试试。