我有一个应用程序,它使用Firebase从服务器接收URL.收到URL后,该URL上的文件将自动保存在本地存储中(它们是gpx文件).
但在此之后,我希望我的应用程序提示用户使用他们在手机上安装的任何导航应用程序打开下载的文件.类似于你自己去文件管理器时,点击一个文件,然后系统会显示所有可以打开该文件的应用程序,并让你选择(或者直接用你的默认设置打开它,如果你有的话).
我一直无法找到任何相关内容,包含"android studio"和"open file"的搜索主要显示有关如何自行管理源文件的教程,因此它们根本没用.
我有一个Android应用程序,基本上存储了保存在用户手机上的gpx文件列表.当用户点击应用程序中的文件名时,它应该提示用户打开gpx文件,其中包含手机上可用的任何路由应用程序.现在我正在测试在奥斯曼打开文件.问题是,奥斯曼德正在开放,但随后立即崩溃.
尝试打开文件的代码是这样的:
File gpxFile = new File(Path);
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
Uri gpxUri = FileProvider.getUriForFile(view.getContext(), AUTHORITY, gpxFile);
intent.setDataAndType(gpxUri, "application/gpx+xml");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
gpx文件看起来像这样:
<?xml version="1.0"?>
<gpx creator="{CREATOR}" version="1.1" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
<wpt lat="{LAT_1}" lon="{LON_1}">
<name>{WPT_NAME_1}</name>
</wpt>
...
<wpt lat="{LAT_N}" lon="{LON_N}">
<name>{WPT_NAME_N}</name>
</wpt>
<trk>
<name>{TRACK_NAME}</name>
<trkseg>
<trkpt lat="{LAT_1}" lon="{LON_1}"></trkpt>
...
<trkpt lat="{LAT_N}" lon="{LON_N}"></trkpt>
</trkseg>
</trk>
</gpx>
Run Code Online (Sandbox Code Playgroud)
起初我认为gpx文件的格式有问题,但如果我手动打开Osmand并尝试使用"配置地图" - >"Gpx轨道"导入文件,则轨迹在地图上显示正常,包括航点.
LE:这是我在奥斯曼试图开始时得到的错误:
08-16 17:28:00.524 5681-5762/? E/net.osmand: RenderingRuleProperty Rendering parse in strokeWidth_2
08-16 17:28:00.524 5681-5762/? E/net.osmand: RenderingRuleProperty Rendering parse in strokeWidth_2
08-16 …
Run Code Online (Sandbox Code Playgroud) 我有一个应用程序,我需要从数据库中检索大量的行,然后在屏幕上打印它们.我检查了mysql查询,这不是问题所在.问题是所有行都需要打印在同一页面上,没有分页,而且需要很长时间(我说的是一个带有几行行的表).有什么方法可以加快速度吗?我在Google上发现的唯一一件事是使用","而不是"." 使用echo时 我将测试这个以确定是否有任何改进,但我不确定它会产生如此大的差异.
当我从注册表单中保存信息时,我在用户名和电子邮件字段上有一些验证规则(我已粘贴下面的规则).使用saveAll()函数自动调用验证.
问题是用户名字段上的isUnique规则根本不起作用(不返回任何错误).此字段的其他规则工作正常,电子邮件字段的唯一验证也有效.当两条规则基本相同时,我似乎无法弄清楚为什么会发生这种情况.
var $validate = array(
'username' => array(
'isUnique' => array (
'rule' => 'isUnique',
'message' => 'This username already exists.'),
'custom' => array (
'rule' => array('custom', '/^[A-Za-z0-9,\.-_]*$/i'),
'message' => 'The username can only contain letters, numbers, _, - and .'),
'minLength' => array(
'rule' => VALID_NOT_EMPTY,
'message' => 'You must fill in the username.')
),
'email' => array(
'isUnique' => array (
'rule' => 'isUnique',
'message' => 'This email address already exists in our database.'),
'valid' => …
Run Code Online (Sandbox Code Playgroud)