android 系统文件目录怎么打开

android 系统文件目录怎么打开,第1张

Intent intent = new Intent()

intent.setAction(android.content.Intent.ACTION_VIEW)

File file = new File(文件路径)

intent.setDataAndType(Uri.fromFile(file), "video/*")

startActivity(intent)

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打开内置的浏览器。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/11809282.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-18
下一篇 2023-05-18

发表评论

登录后才能评论

评论列表(0条)

保存