I'm using xam.plugin.media to get the file path of the image selected. Working with a single image is fine, but I'm having trouble selecting multiple images.
This is my code:
List<MediaFile> mediaFile;
...
private async void AddAttachments(object sender, EventArgs e) {
await CrossMedia.Current.Initialize();
if (!CrossMedia.Current.IsPickPhotoSupported) {
await DisplayAlert("Error", "Your phone does not support photo uploads. Please proceed without attachments.", "Okay");
return;
}
mediaFile = await CrossMedia.Current.PickPhotosAsync();
if (mediaFile == null) {
return;
}
}
Despite using PickPhotosAsync(), it still selects a single photo. I was expecting something where I can check images I want to upload like other mobile applications.
Unfortunately, you can't (kind of). It is supposed to be working, but there was an issue about this back in 2018-2019, which got marked as solved, even though the user kept complaining about it not working reliably/always.
Link to the feature request/issue here.
There is a new issue, that got registered recently (April 2020) here.
My advice is to subscribe to it and comment, so that the developer will know that you are experiencing some issues with this functionality also. If you can, you can also create a sample project and upload it, so that they can quickly fix it.
However, in my experience, this package hasn't been frequently updated, so you might have to wait a bit.
Related
Hey im having issues with a website in the jxbrowser. it seems like it is running into a timeout or whatever and then in the jxbrowser there is a dialog showing up "website not responding" and i can click on "reload" or "leave".
Can I in any way access this dialog and overwrite it? For instance everytime i would get this dont ask but go to the homepage instead?
I'm having trouble finding this if it is even possible.
I found a solution. JXBrowser has a RenderAdapter where a function exists onRenderUnresponsive wich can be overridden. Look at this: https://jxbrowser.support.teamdev.com/support/solutions/articles/9000091687-detecting-unresponsive-web-page
In my case I simply want to reload the website:
Browser browser = new Browser();
browser.addRenderListener(new RenderAdapter() {
#Override
public void onRenderUnresponsive(RenderEvent event) {
browser.reloadIgnoringCache(false);
}
});
I recreated the example of a webkit that displays the content of a textEdit containing HTML: http://qt-project.org/doc/qt-4.8/webkit-previewer.html
I changed it so rather than the webkit HTML being changed upon clicking the button, it's changed upon the text in the textEdit being changed:
// changed when button is click. Works fine.
void Previewer::on_previewButton_clicked()
{
// Update the contents in web viewer
QString text = htmlTextEdit->toPlainText();
webView->setHtml(text);
}
// change when text is changed. Crashes.
void Previewer::on_htmlTextEdit_textChanged()
{
// Update the contents in web viewer
QString text = "<html><body><h1>No crash!</h1></body></html>";
webView->setHtml(text);
}
This causes the program to crash as soon as it starts. I altered the program to run the function only a bit later (I thought maybe something needed to be initialized) but it still crashed once it reached the textChanged function. Why is it crashing? How can I fix this?
Your program is entering an infinite loop because, in the example, there's a connection between the webView's loadFinished(bool) signal and the text/html editor's updateTextEdit() slot.
Basically, editing the HTML causes the page to load again, which causes an update to the editor, which causes the page to load again, so on and so forth.
A quick way I solved this was to add a static bool flag to the updateTextEdit SLOT/function that only allows it to run once.
void MainWindow::updateTextEdit()
{
static bool once = false;
if (once) {
return;
}
once = true;
QWebFrame *mainFrame = centralWidget->webView->page()->mainFrame();
QString frameText = mainFrame->toHtml();
centralWidget->plainTextEdit->setPlainText(frameText);
}
Doing this worked for me, but your version might work differently than mine. I followed the example closely, but added an htmlchanged() slot to the previewer class, and made the connection like so:
connect(centralWidget->plainTextEdit, SIGNAL(textChanged()), centralWidget, SLOT(html_changed()));
Also, I'm no expert, but I'm pretty sure this is not the best way to get around this, and I assume that updateTextEdit() needs to run more than once. It'll work for the time being, though.
I know this kind of question has been asked many times.
Yet I don't succeed in displaying an image from my db on a page.
I tried the following method.
protected void Page_Load(object sender, EventArgs e)
{
//Get the picture id by url
//Query here
byte[] picture = queryoutput;
Response.ContentType = "image/jpeg";
Response.BinaryWrite(picture);
}
Link to get the image.
<asp:Image runat="server" ImageUrl="~/givememypicture.aspx?pic=3" ID="testimage" />
The <asp:Image /> tag is located in between <asp:Content > tags.
When I run this code and check in firebug, it simply states 'Failed to load fiven URL'.
I also tried putting the Respone.Con...(picture); part into a public method and call that method with the byte var given.
I'm quite new to asp.net, but I have somewhat more experience in c#.
I start to really dislike asp.net... I have been struggling with this for about 20 hours already and tried a lot of options, yet none worked.
The best would be if I could just fill in the picture via the codefile from that same page. It seems quite illogical to me to call another page to load the image from.
Can somebody please tell me what I'm doing wrong here?
Solution: Master page reference removed from the page directive on the page that handles the image response. Also removed everything else except for the #page directive itself within the aspx file.
try using a handler file (.ashx) put the code form your page_load in that lie so
public void ProcessRequest (HttpContext context) {
//Get the picture id by url
//Query here
byte[] picture = queryoutput;
Response.ContentType = "images/jpeg";
Response.BinaryWrite(picture);
}
public bool IsReusable {
get {
return false;
}
}
then call the handler file and pass the correct querystring items from the
this should then work
There's an error in your path reference...
ImageUrl="/~givememypicture.aspx?pic=3"
should be:
ImageUrl="~/givememypicture.aspx?pic=3"
~ is shorthand for "the application root" and needs to be followed by a slash to indicate that it's a directory. Think of it as similar to other path shorthand notations such as . and ...
Make sure you call Response.Flush(); and also Response.End(); and see if that does the trick
Also, your content type has a misspelling. Is not "images/jpgeg" I think it's "image/jpeg"
EDIT: Yes, I just confirmed in Wikipedia that the correct content-type is image/jpeg.
I do this all the time. Here's some sample code:
Response.ContentType = "image/jpeg";
Response.BinaryWrite(bytes);
That's all there is too it. If it's not working, then something is probably wrong with your data.
A flush is not required. I have working code for this open on my screen right now.
I would suggest that you try writing that buffer of data to a file and see if it opens up as a valid picture. I bet something's wrong with that data.
Also, it's a good idea to enable browser side caching for your dynamic content. Here's a GREAT link that shows exactly how to do that, which will boost your performance / scalability a lot.
http://edn.embarcadero.com/article/38123
I have a timer in my application. For every 30 min, it will hit the web services and fetch the data and updates the UI. The application was working fine till yesterday. Suddenly, because of some issue, the web services were not available for some time. During that period, Application displayed the RPC Error multiple times(More than 100 alert boxes) in alert window. Because of this alert boxes, my application was hanged and i was not able to do anything.
I have tried several approaches, but nothing worked.Finally, I have tried to use a flag. In all the approaches, this looked promising. so i have implemented it.Basically, in this approach whenever we open an alert we will set a flag.While opening and closing alert we will reset this flag. But it didn't work as expected. Is there any approach, which can help us in avoiding multiple alert windows.
Please help me, to fix this issue.
I would write wrapper for opening alerts, and use only this wrapper, not Alert.show in the code:
public class AlertWrapper {
private static var lastAlert:Alert;
public static function showAlert(text:String, title:String):void {
if (lastAlert) {
PopUpManager.removePopUp(lastAlert);
//or
//return; //ignore last alert
}
lastAlert = Alert.show(text, title, null, 4, onAlertClose);
}
private static function onAlertClose(event:CloseEvent):void {
lastAlert = null;
}
}
Imports are missing, but I hope the idea is clear.
I have an application with a launch page that needs to determine what is already opened, so it does not reopen things that are opened already in another new tab. In Firefox, I was able to make this work, by using window.sessionStorage to store the titles of pages that are open, and then use window.opener with the following code to remove the titles from the list.
Gecko Session Storage Info Page
if (window.sessionStorage) {
if (window.sessionStorage.getItem(code)) {
return; // page already open
}
else {
window.sessionStorage.setItem(code, code);
window.open("Sheet.aspx", "_blank");
}
}
And on the pages that are opened:
function signalPageExit() {
if (window.opener.sessionStorage) {
window.opener.sessionStorage.removeItem(
document.getElementById("runcode").childNodes[0].textContent);
}
This doesn't work in IE so I decided to use a cookie strategy, but the cookies were never successfully deleted from code on the dynamically launched pages, and therefore pages couldn't be reopened from the launch page once they had been launched until the cookie expired.
My second attempt was to define my own sessionStorage when it did not exist. That looked like this:
function setStoreItem(name, val) {
this.storage[name] = val;
}
function getStoreItem(name) {
return(this.storage[name]);
}
function removeStoreItem(name) {
this.storage[name] = null;
}
function sesStorage() {
this.storage = new storageData();
this.setItem = setStoreItem;
this.getItem = getStoreItem;
this.removeItem = removeStoreItem;
}
// storage object type declaration
function storageData() {
}
// IE 7 and others
else {
window.sessionStorage = new sesStorage();
window.sessionStorage.setItem(code, code);
window.open("Sheet.aspx", "_blank");
}
But it seems the real session storage is special, this ordinary object of the window did not stay alive across postbacks and therefore when my launch page posted back, the list of created page titles was wiped out.
So now I'm looking for a way to make this work. I have a launch page called scoresheets.aspx that creates dynamic pages based on user requests. These pages share a substantial amount of javascript code that can be modified to make this work.
I don't want to refresh the launched pages when a user tries to reopen them, but if there is some way to detect the titles of opened pages or some other way to use window.opener to communicate with the same persistence that sessionStorage has, I'd be glad to use it.
Eric Garside’s jStore plugin provides a jquery based api to several client side storage engines.
you should go with that cookie strategy and set those cookies to expire when the windows (tab) is closed. that should work across browsers.