I'm downloading image using url like below,
final String url = article.image.url;
String parentFolder = ""+article.category_id;
final String fileName = ""+article.image.id;
FileManager fileManager = BDevice.getFileManager(mContext);
final File file = BDevice.getFileManager(mContext).getFile(""+article.category_id, parentFolder, fileName);
Uri uri = null;
if (fileManager.isFileExists(file.getAbsolutePath())) {
uri = Uri.fromFile(file);
} else {
if (url != null) {
uri = Uri.parse(url);
}
}
holder.image.setImageURI(uri);
But this is working for this url "https://citylanedev.blob.core.windows.net/citylane/2016/10/Pharmacie_Icon.png"
and not working for this url "https://dev.citylaneapp.com/wp-content/uploads/2016/09/france-mont-saint-michel-2.jpg". After remove 's' from the second url like "http://dev.citylaneapp.com/wp-content/uploads/2016/09/france-mont-saint-michel-2.jpg" its working fine. But i dnt want to remove 's' from the url. I want to download image from the second url. So could you please suggest me any idea to do this?
when I try to open the urls in the browser, the second one
gives that warning, mostly it's a server issue that the server claims it's secured but probably it's SSL Certificates aren't installed, you should contact the server admin.
Related
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);
}
My URL doesn't change, however, pdf file changes.
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}";
How to open a online stream assets in android.
I had used Intent, but the file gets downloaded and not getting opened in browser.
var uri = Android.Net.Uri.Parse(Url);
Intent intent = new Intent(Intent.ActionView, uri);
StartActivity(intent);
Don't want to use Web view. Any help ?
How to open a online stream assets in android.
You could using google doc service to achieve this function, it just need you
to modify your Url like this :
string Url = "https://docs.google.com/gview?embedded=true&url=" + strPdf;
//Eg :string Url = "https://docs.google.com/gview?embedded=true&url=" + "https://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf";
var uri = Android.Net.Uri.Parse(Url);
I have a WebApi project and a Android client, and I need to upload some images from the WebApi using App42, the problem is, in this tutorial, it must have a StringPath, but I dont have a stringPath, because the image is gonna be send by the Android Client for the Api and then Save those images. Do I have to send the image from Android as Base64 and then create a tempFileObject as Bitmap and then put the stringPath?
String name = "MyPic";
String userName = "Nick";
String filePath = " file path from gallery /sd card";
String fileType = "IMAGE";
String description = "This is my holiday pic";
Upload upload = uploadService.UploadFileForUser(name,userName,filePath,fileType,description);
// File will get uploaded in App42 cloud with above snippet.
IList<Upload.File> fileList = upload.GetFileList(); // This will have only single file uploaded above
for (int i = 0; i < fileList.Count; i++)
{
Console.WriteLine("fileUrl is " + fileList[i].GetUrl());
//This will return uploaded file URL
}
If I understood the query then you don't have file saved in the device local file storage. If Yes, then you can use another API which will ask you the InputSteam of the image as parameter.
I hope this helps.
I'm making an app that uses MediaPlayer to play internet radio streams.
Research online tells me that it's easiest to use a URI.
I was wondering how I convert this link to a URI?
The tutorial I found was a little confusing on this point: http://teamrock.planetwideradio.com:8000/teamrockhigh
Use the toURI method, which
Returns the URI equivalent to this URL.
In your case:
URL url = new URL("http://teamrock.planetwideradio.com:8000/teamrockhigh");
URI uri = url.toURI();
It depends if you are using the link as an URL or maybe just a string. If you just look for a way to convert an URL to an URI then the code is rahter short:
// Convert a URL to a URI
URI uri = null;
URL url = null;
try{
url = new URL("http://teamrock.planetwideradio.com:8000/teamrockhigh");
uri = url.toURI();
}
catch (URISyntaxException e) {
// Exception handling
}
You can also use the string directly to create an URI object:
URI uri = new URI("http://teamrock.planetwideradio.com:8000/teamrockhigh");
What I am trying to achieve is sounds very familiar, it has been posted many times here and there in Stack Overflow as well, but I'm unable to get it done.
The scenario is, I receive a mail with attachment having custom extension in it. The extension is recognized by my app and it needs the FilePath to process it.
Currently, when I get the attachment in my app using getIntent().getData() all I get is path of the form content://
I have seen methods to convert media content of the type content:// to FilePath like /sdcard/file.ext but I was unable to convert the attachment using that. May be its obvious.
Is there any way that I can process the content:// type without actually downloading it.
Currently from the k9 mail app, when I get the custom extension, it shows my app in the list and opens it through it, but I need FilePath like /sdcard/file.ext and I'm only able to get content:// type.
I hope I made the question clear.
Please Help.
Regards.
A content:// Uri does not necessarily point to a file on the sdcard.
It is more likely that it points to any kind of data stored in a database
or to a content provider that gives you access to the private file storage of another app.
I think the later one is the case with mail attachments (if the content provider is not requesting it directly from a web server). So converting the content:// Uri to a path will not work.
I did the following (not sure if it works also for k9 mail app)
Uri uri = intent.getData();
if (uri.getScheme().equals("content")) {
String fileName = ContentProviderUtils.getAttachmentName(this, uri);
if (fileName.toLowerCase().endsWith(".ext")) {
InputStream is = this.getContentResolver().openInputStream(uri);
// do something
} else {
// not correct extension
return;
}
} else if (uri.getScheme().equals("file")) {
String path = uri.getPath();
if (path.toLowerCase().endsWith(".ext")) {
InputStream is = new FileInputStream(path);
// do something
} else {
// not correct extension
return;
}
}
The attachment name can be found by
public static String getAttachmentName(Context ctxt, Uri contentUri) {
Cursor cursor = ctxt.getContentResolver().query(contentUri, new String[]{MediaStore.MediaColumns.DISPLAY_NAME}, null, null, null);
String res = "";
if (cursor != null){
cursor.moveToFirst();
int nameIdx = cursor.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME);
res = cursor.getString(nameIdx);
cursor.close();
}
return res;
}