Advice about AsyncTask - android-asynctask

I´m new with Android and I need any advice about Asyntask topic.
Currently I´ve a app that I write some information and using AsyncTask I send to SAP System (BackEnd) using HttpURLConnection. I´m going to write a second Asyntask to send a photo using FTP protocol to another server.
So I´ve going to have two Asyntask one for the data with SAP and another with a ftp server to send a photo.
I have a listview with several lines of information, for each row I want use the first Asyntask and if it´s OK, I will use the second Asyntask.
When the first row was processed (with OK or wrong finish), the I want start with the first Asyntask and the second Asyntask and go on...
So How can I do it ????
Somethin like this:
http://shamansir.github.io/blog/articles/10-useful-solutions-for-android-developer/
(point 9. AsyncTask Queues )
http://blogs.innovationm.com/multiple-asynctask-in-android/
Can I chain async task sequentially (starting one after the previous asynctask completes)
Any advice ????
Thansk in advance

You can call another asynctask from onPostExecute. It will be called after the first one has finished, and the call will be made from ui thread.

Related

Is it possible to get another person's UI in Google Apps Script?

In Google Apps Script when you use the property: DocumentApp.getUi(), it gets the UI of the person who is using it. If you used DocumentApp.getUi().alert(), then it would send an alert to the person who is using the script. I am wondering if there is maybe a way to alert another person's UI in Google Apps Script and not the person who is using the script. Here is a sample of my code:
DocumentApp.getActiveDocument()
.removeViewer(userName.getResponseText())
.removeEditor(userName.getResponseText());
DocumentApp.getUi()
.alert("Your access is being removed.")
Now it would be wonderful and imagine all the possibilities if that were possible! Someone please help!
It is not possible to access the UI of any browser except the one which invoked the function. This is also why time driven triggers cannot display UI modals (they are executing nonlocally).

How to generate log in service now when a browser is closed?

I need to generate logs in service now whenever the browser is closed or the session is expired. I tried using global business rule but couldnt achieve it. It will be greatfull if i can if i get an idea to achieve this.
Thanks in advance.
I assume you already know how to generate a log and such in ServiceNow, and the problem you're having, is how to run code when the user closed their browser.
The best solution would probably be to create an onload client script which sets onbeforeunload to a function that triggers a log.
More on that here: https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload
For the second part of your question, user sessions are tracked in a "user sessions" table. If you want to also log when theirs expires, you can do so with a business rule on that table.
You can use
GlideAjax to call from your client script to a server side script include.
Look at GSLog
Try this one
var gl = new GSLog("com.snc.sla.tasksla.log", "TaskSLA");

Is it possible to chain commands via FormFlow?

Dialog can do almost everything according to the bot framework documentation, but it will take a lot more time to investigate than FormFlow. I failed to find a place that have lots of samples of bot framework yet. At the moment, before I spend a lot of time to try dialog, anyone know if it's possible to chain commands using FormFlow.
The work I am trying to do is to code a chain of commands:
query records
select a record from the results
actions/operations on the record
etc...
Really appreciate if anyone familiar with Bot Framework can help me on this.
Use the IDialogStack.Call method in your FormFlow handlers to call another dialog and push it on the stack.
Then use the IDialogStack.Done method to pop it off the stack. Both described here.

Xamarin MvvmCross - MvxFragment communicating with MvxActionBarActivity

I currently have a project in Xamarin and I am using MvvmCross. I have an MvxActionBarActivity that hosts MvxFragments. Now when I want to close the entire MvxActionBarActivity, the event begins in the Fragment and I want to tell the MvxActionBarActivity to close. Calling Close(this) in the fragment viewmodel is not working.
I have considered using MvxMessegner to send message from one viewmodel to the other but due to the relationship of a fragment and an activity I am wondering if there is a better way to do this.
Any help would be much appreciated.
Thank you!
When you want to close an Activity you need to call Finish(). This will close that activity and go back to that what is on the backstack.
If you want to call that from your viewmodel you should use a custom presenter: http://gregshackles.com/presenters-in-mvvmcross-navigating-android-with-fragments/

strutrs2 and ajax(Displaying dynamic value on jsp)

Im pretty new to struts2 and Ajax ,Actually i have a drop down menu in JSP lets say first.jsp, When user select a choice from dropdown menu,I am calling a function of Action class lets say Method1.In this method i am fetching some value from DB(lets say:a,b,c) and one value from java memory lets say d.Then I am forwarding to second.jsp and display all the parameters(a,b,c and d) in tabular format.
Now problem is that the parameter d is dynamic ,this is updating by some other application and if its change then I have to show it on JSP wihout any action.
One solution is I use in second.jsp , so after interval of 10 second again Mehod1 will call and it will fetch value(a,b,c) from db and updated value of d from java memory. and disply it to second.jsp.But in this case i am unnecessary retrieving value from db while my purpose is just to get value d from memory.This is working but this is causing my application to slower.
Can any body suggetst some other solution? or can i do it using ajax and how?
Any other advice? any help is appreciated.try to be more clear, i'm in lack of ideas in this problem, even it sounds like a classic :I have spend hours trying to play around with this but have got nowhere
Okay... What you're asking is a little fuzzy so let me rephrase:
You have a user (USER1) who opens a web page and sees some data.
You have a second user (USER2) (who may be an application) who is able set a value from time to time.
When USER2 updates that value you want USER1 to see it change in their open browser window?
If this is the case you need to understand basic ajax. For that get these demo applications working:
This example uses dojo and perhaps the S2 ajax tag lib I don't remember I prefer not to use ajax tags (as they are deprecated and prefer jquery for ajax):
http://struts.apache.org/2.x/docs/struts-2-spring-2-jpa-ajax.html
This example here shows a very similar application but using jquery, no tag library, upgraded to Spring 3, it still needs polish:
http://www.kenmcwilliams.com/Downloads/
Now that you know how to get data via ajax, look at the request with firebug. You'll see that the request is just like a typical function call, the browser keeps waiting for the data to come back.
What you do is simply not return from the action until new data is provided. This is called long polling see: http://en.wikipedia.org/wiki/Comet_%28programming%29#Ajax_with_long_polling
If you have not written a simple chat program, using just terminal windows I recommend you do so. Two windows per client (client-send, client-receive windows) and you'll need a server program. I remember hacking one together in a few hours using _Thinking In Java 2nd Edition (Later books took out the networking section if I remember correctly). Anyways between understanding client server interaction and long polling will let you get things working. It would be fun to extend the simple terminal based chat application to a S2 ajax chat application. Would make an awesome tutorial! PS: This is just an application of the producer/consumer problem (If you understand that then I guess you don't need to do the fun exercise).
The interfaces would look very pretty if the server was managed by spring. I know there must be nice servers already written but I am not familiar with any, but would love to hear of one.

Resources