Android.Net.Uri更改缓存时间 [英] Android.Net.Uri change caching time

查看:54
本文介绍了Android.Net.Uri更改缓存时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改缓存时间?在服务器上更新PDF文件时,我收到通知.我得到相同的链接,但有另一个(先前的)文档.由于URL会对上一个文档进行哈希处理,因此它将打开旧文档,而不是更新的文档.

How can I change caching time? I receive a notification when the PDF file is updated on the server. I get the same link, but with another (previous) document. Since URL hashes the previous document, it opens the old one, not the updated one.

Android.Net.Uri uri = Android.Net.Uri.Parse(url);
Intent browserIntent = new Intent(Intent.ActionView, uri);
try {
  context.StartActivity(browserIntent);
}
catch (ActivityNotFoundException e) {
  Console.WriteLine(e);
  Toast.MakeText(context, "Install PDF reader", ToastLength.Short);
}

我的URL不变,但是pdf文件却改变了.

My URL doesn't change, however, pdf file changes.

推荐答案

我解决了我的问题,只是更改了URL.现在,每个指向pdf文件的URL都是唯一的,并且不会被缓存.

I solved my problem, I just changed the URL. And now every URL to the pdf file is unique and not cached.

url = url.Replace(" ", "%20");
url = $"{url}?random_number={new Date().Time}";

这篇关于Android.Net.Uri更改缓存时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆