Android如何触发intent打开指定目录

Android如何触发intent打开指定目录,第1张

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

文件浏览器就是常见的文件管理app对吧?关键不在定位path,我认为(特别强调,我认为),解决方案,

1,拥有文件管理app源码,修改或者了解是否 支持其他应用的参照启动方式,就是非launcher启动时,是否能处理path或uri参数。

2,在你的app中附加,文件浏览(功能)。


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

原文地址: https://outofmemory.cn/tougao/8001675.html

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

发表评论

登录后才能评论

评论列表(0条)

保存