Wednesday 15 February 2012

android - Using a single intent to retrieve multiple records vs a separate intent for each record -


I am trying to assess the benefits and costs of using a long intent which is up to five different intentions. is using.

Users of my app download records from the web, which are parsed in the database, the user can download records for between 1 and 5 people at any time.

I have an app like this:

  Private onclicklists mySubmitOnClick = New OnClickListener () {@Override Click Public Zero (see V) {ArrayList & Lt; String & gt; IdsOfRecordsArray = getIdsOfRecordsToDownload (); Intentional Intentionate = New Intent (getActivity (), RetrieveData.class); Messenger Messenger = new Messenger (handler); IntentToRetrieve.putExtra ("Messenger", Messenger); Intentato-Retrog .putstringirerextextra ("IDList", iiDOfreaksEre Array); . V.getContext () startService (intentToRetrieve); ShowDialog ("Some Messages"); }}   

This works but due to the time required to parse the data, I sometimes get a timeout error.

I changed it to:

  Private Onclick Lester MySmittanceClick = New OnclickListener () {@ Override Public Wide OnClick Click (see V) {ArrayList & lt; String & gt; IdsOfRecordsArray = getIdsOfRecordsToDownload (); While (iCount & lt; idsOfRecordsArray.size ()) {ArrayList & lt; String & gt; CurrentID = New Arrestist & lt; String & gt; (); CurrentAthleteID.add (athleteIdArray.get (iCountAthletes)); Intentional Intentionate = New Intent (getActivity (), RetrieveData.class); Messenger Messenger = new Messenger (handler); IntentToRetrieve.putExtra ("Messenger", Messenger); Ententto-Retrieve.Tutstring Arrest Extra ("IDList", current ID); . V.getContext () startService (intentToRetrieve); ShowDialog ("Some Messages"); ICount ++; }}   

So now I can take five to five (5) intervals at the same time. It seems stable, though, progress is a bit of a nuisance to handle conversations. is. If I open only 1 dialogue box, then this process closes before it completes.

Any idea which has a better attitude? Or maybe I should leave both for some other method?

Work in the background, using an IntentService. You can stop as much as you want, but IntentService will do the same procedure at a time. In the meantime, you will not be out of time and users can continue to work. I think users will accept that the results do not come immediately, as long as they are waiting, they can do anything else

See an Android training class as an example.

No comments:

Post a Comment