Android :: Way To Return Result Of AsyncTask

Jan 21, 2010

According to my research, which includes reputable sources (Mark Murphy et al), the most preferred way of polling a remote source and presenting said data to the user is by creating a service and using AsyncTask within that service to do the polling. I have done that.But, when I read the docs there seem to be several "Threading Rules" that conflict with this way of doing things: "The task instance must be created on the UI thread." and "execute(Params...) must be invoked on the UI thread." As stated, I have created the task instance on the Service thread (not the UI thread). Am I missing something? Also, when the AsyncTask finished, I sent out a Broadcast on onPostExecute, which is then picked up by the Activity, telling it to retrieve the final value again from the service (since I couldn't obviously update the UI from the service). I couldn't figure out any other way to return the result of the AsyncTask. Is this the correct practice?

Android :: way to return result of AsyncTask


Android :: Instance Variable Of Activity Not Being Set OnPostExecute Of AsyncTask - Return Data From AsyncTask

Jul 28, 2010

I'm trying to figure out the correct way to create an AsyncTask to retrieve some data from the internet and then to take that data and bundle it up in an Intent and pass it to a new activity(A list display). So in the first activity I just have an EditText and Button. In the event of an OnClick the task should be called and when it is finished the data should be bundled inside an Intent and passed to the next Activity. The problem is when I take the results from onPostExecute and set them to an instance variable of the main activity, that instance variable is still null when the task is complete. Here is the barebones version of the code:

CODE:...........

When I debug the application I see onPostExecute does contain a valid PlacesList full of results, so why is the instance variable places set to null after the task is executed? I am going about "returning data" from an AsyncTask incorrectly?

View 1 Replies View Related

Android :: How Does Service Return Result To Activity

Oct 1, 2010

i seem to have a classic task, yet i can't find any examples on how to do it.i want to download something. well i call a web service and get a response but its pretty much the same.in order to do this i have an activity that starts a service that spawns a thread that does the job.now i would like to use the data i got in the activity that started the service.(i assume that starting another activity to handle the job of displaying the result would be simple)my problem is how does the service notify an activity (the one that started it or another one) of something.

View 1 Replies View Related

Android : Put Query In A Loop To Return Result Set One By One?

Nov 18, 2010

I have SQLITE DB query which returns me one record at a time.
This is the query :-
rawQuery("SELECT id, category_id, title, text FROM customer WHERE (reads = (SELECT MIN(minReads) FROM categories)) AND status = 'a' ORDER BY rating DESC, rand_index DESC LIMIT 1 ",null);

If I want to fetch next record as we are applying limit in my sqlite query above i m unable to get next record. Limit 1 is necessary as i have thousands of record in my db.

How can I fetch next record without modifying the existing query. I cannot apply loop on this as I have lots of records and I don't want all the record at the same time. I want it to be fetched dynamically one by one. I want to be be something like where I can store result in an array as I might need old record as well while getting next record.

View 2 Replies View Related

Android : Return A Result (startActivityForResult) From A TabHost Activity?

Mar 23, 2010

I have 3 classes in my example:
Class A, the main activity. Class A calls a startActivityForResult:

Intent intent = new Intent(this, ClassB.class);
startActivityForResult(intent, "STRING");

Class B, this class is a TabActivity:

Intent intent = new Intent(this, ClassC.class);
tabHost.addTab...

Class C, this class is a regular Activity:

Intent intent = this.getIntent();
intent.putExtra("SOMETHING", "EXTRAS");
this.setResult(RESULT_OK, intent);
finish();

onActivityResult is called in Class A, but the resultCode is RESULT_CANCELED instead of RESULT_OK and the returned intent is null. How do I return something from the Activity inside a TabHost?

I realize that the problem is that my Class C is actually running inside of Class B, and Class B is what is returning the RESULT_CANCELED back to Class A. I just don't know a work around yet.

View 4 Replies View Related

Android :: AsyncTask Return In Another Thread Than UI?

Jul 21, 2010

Android documentation says that AsyncTask postExecute() is called on the UI thread. I was under the impression that postExecute() was called from the Thread where execute() was called : I have been using an AsyncTask in a background Service with its own thread, and postExecute() was called in the service thread, not the main thread. However, I recently had an issue with the postExecute() not being called at all, while an exception was thrown : " sending a message to a Handler on a dead thread". How is it exactly :

- shall AsyncTask be used ONLY from the main thread ?
- if not, in which thread postExecute() is supposed to be called : always the UI thread, or the execute() calling thread ?

View 2 Replies View Related

HTC EVO 4G :: 30 Day Return Policy - Out Of Stock At Return?

Jun 27, 2010

If I need to return my phone before the 30 days are up and they are out of stock, will they still honor the return policy and just call you when they have one available or will you have to stick with the phone that you have?

View 5 Replies View Related

Android : Can I Get Result From A Sub Activity?

Aug 5, 2010

When user presses a button from a webview, I open a scrollview activity with some buttons and edittext fields.

Once the user enters the fields and presses the 'create' button, from scrollview activity, I want the results from the called activity to be accessible. How can I do thi?

View 1 Replies View Related

Android :: Intent And URI Conversion Result

Feb 14, 2009

We can convert from Intent to URI and from URI to Intent. From Intent to URI string Intent intent1 = new Intent ();
String uriString = intent1.toURI ();
From URI string to Intent Uri uri = Uri.parse (uriString);
Intent intent2 = new Intent ();
intent2.setData (uri)

After conversion, intent1 and inten2 should be same. for example:
Intent intent1 = new Intent ();
intent1.addCategory (Intent.CATEGORY_HOME);
intent1.addCategory (Intent.CATEGORY_LAUNCHER);
Log.v ("", "Intent1 = " + intent1);
if (intent1.hasCategory (Intent.CATEGORY_HOME))
Log.v ("Intent1", "#1 hasCategory TRUE");
else Log.v ("Intent1", "#1 hasCategory FALSE");
String str = intent1.toURI ();
Uri uri = Uri.parse (str);
Intent intent2 = new Intent ();
intent2.setData (uri);
Log.v ("", "Intent2 = " + intent2);
if (intent2.hasCategory (Intent.CATEGORY_HOME))
Log.v ("Intent2", "#2 hasCategory TRUE");
else Log.v ("Intent2", "#2 hasCategory FALSE");
result Intent1 = { categories=android.intent.category.HOME,android.intent.category.LAUNCHER} } #1 hasCategory TRUE

Intent2 {data=#Intent;
category=android.intent.category.HOME;
category=android.intent.category.LAUNCHER;
end } #2 hasCategory FALSE

In this sample code, Intent2 is a conversion result from Intent1. If you run this sample code, Intent1 result and Intent2 result are different. Because Intent1 and Intent2 have a same Intent.CATEGORY_HOEM, the result should be Intent1 and Intent2 is TRUE (intent.hasCategory). I think this is bug. And the hint is Intent1 and Intent2 's toString result is different.
Intent1 = {categories=android.intent.category.HOME,android.intent.category.LAUNCHER}
Intent2 = { data=#Intent;category=android.intent.category.HOME
category= android.intent.category.LAUNCHER;end }

I don't know how to convert Intent to URI(String) and convert URI (String) to Intent. I want to save Intent to DB and read Intent from DB.

View 3 Replies View Related

Android :: Geocoder Not Returning Result

May 8, 2009

My application that uses geocoding was working fine till last week and now all of a sudden am not getting proper data from the same.

I used getLocality() , which was returning CITY name previously. But now it is returning NULL.

Is something changed? or Has someone faced the same issue?

My application is on SDK 1.0

View 12 Replies View Related

Android :: Opencore Test Result

Mar 22, 2010

Here is what I got while running a test case of open core . *************** # pvplayer_ engine _test -test 1 1 SDK Labeled: PVDEV_ CORE_RELEASE_6.506.4.1 built on 20090312 Test Program for pvPlayer engine class. Input file name 'test.mp4' Test case range 1 to 1 Compressed output Video(No) Audio(No)Log level 8; Log node 0 Log Text 0 Log Mem 0 Starting Test 1: Open-Play-Stop-Reset Results for Test Case 1: Successes 1, Failures 1 Total Execution time for file test.mp4 is : 2.712000 seconds# *************** I want to ask why it shows 1 success and 1 failure . there should be only 1 pass or 1 fail only . Do each test case have multiple sub-tests within them ? which class in source code finally decide whether it is pass or faiL?

View 2 Replies View Related

Android :: No Result On Sqlite Query

Sep 24, 2010

I create a table like that

CODE:...........

I update it this way

CODE:..........

I do see the change in eclipse with DDMS questoid

But when i try to retrieve the value I get nothing ....

CODE:.........

I've tried some variant like

CODE:............

With no success

Is this problem come from the type (integer) of my column ?

View 1 Replies View Related

Android :: Get Tow Intent Result In OnActivityResult?

Sep 17, 2010

I am using two intent for various action in my activity and i also used onActivityResult for get result,i want to answer for how to get tow intent result in onActivityResult?anybody knows please give sample code for me..

View 1 Replies View Related

Android :: Add A Distance To GeoPoint And Get It As Result?

Jan 27, 2010

I need to draw a circle on my map. I have the GeoPoint and I have the radius of the circle in meters. How do I add a distance to a GeoPoint and get a GeoPoint as a result?

View 3 Replies View Related

Android : TabHost And StartActivity For Result?

Sep 2, 2009

I meet an issue: my activity cannot return result.

I created an activity which has one TabHost. I added three tabs using mTabHost.addTab. Every tab will launch an activity(activity A, activity B, activity C). In activity A, it will call startActivityForResult to start activity A1. The issue is activity A cannot get any result after A1 finish.

What is the reason? How should I do if I want to get return value?

View 3 Replies View Related

Android : Need To Get Result Back From Activity?

Mar 10, 2010

I'm doing some network job in AsyncTask. Sometimes it requires communication with user. (connection is dropped, session is expired and so on). I want to pop up a dialog or launch an Activity, and then, depending on user's input, stop the job or redo it. I can launch any Activity from AsyncTask, but how to get result back? It seems to be possible only if I launch new Activity from another Activity. What are possible solutions?

View 5 Replies View Related

Android :: Open Gallery Via Intent Without Result

Oct 5, 2010

I have a kind of an ApplicationLauncher that has to start the build-in gallery. But I dont want to get any result from that gallery... I just want to start it and want my "Launcher" to close after that.

What ive tried:

CODE:................

But it doestn even work with this flag... as soon as I click on a pic in the gallery, it closes and returns to my "Launcher". Is there any way to achieve what i want to do?

View 3 Replies View Related

Android :: Start Activity From Service - And Getting Result From It

Feb 11, 2010

I have a Service which needs to receive data from external packages. So, to locate the data providing external packages, I use activity- filter and PackageManager.queryIntentActivities function to locate the interesting packages. Now, from each such package, I need to get a ContentProvider URI. So I want to start the external Activity and the external activity will return a result to my service - something like "startActivityForResult". The problem is that there is no way to call "startActivityForResult" from a Service, only Activity can do that, and my project does not have any Activity, and probably can't show UI for the user.

The bottom line: Can anyone suggest a way to get ContentProvider URI from an external package, while my package has only a Service?

View 22 Replies View Related

Android :: Search Youtube And Play Best Result

Oct 15, 2010

How can i search for for a keyword and afterwards play best result in youtube player?

View 1 Replies View Related

Android :: Get Mail Sent Notification In Activity Result

Aug 30, 2010

I am launching a mail activity by
//Sending mail final int SENT_MAIL = 1;
startActivityForResult(Intent.createChooser(i, "Send mail"),SENT_MAIL);
and in
onActivityResult(int req, int res,Intent data)

I am trying to find the result of email sending, so as to confirm if my mail was sent or was discarded by the user. I am receiving null for Intent data.
i.e. data =null
parameter in onActivityResult(int req, int res, Intent data), res is always 0.
ie. res = 0;

View 1 Replies View Related

Android :: Why To Cast This Statement In Order To Get A Result?

Oct 15, 2010

CODE:............................

View 3 Replies View Related

Android :: Method Invoke Problem When Getting Result

Aug 31, 2010

I am try to use reflection to invoke the "List Camera.Parameters.getSupportedFocusModes()" function with the following codes:

CODE:..............................

The log shows it does find the function, however, the result o is always null, why is that?

View 1 Replies View Related

Android : Way To Get Result From Settings Activity Intent?

May 4, 2009

I am currently trying to launch a GPS settings activity using startActivityForResult....however it never seems to be calling my onActivityResult function after it exits. I noticed the docs mentioned that some Intent protocols are not defined to return a result, is this one such example? are there any flags that I could set to either make the settings activity call onActivityResult, or even better make my activity block until the launched activity returns?

View 5 Replies View Related

Android : Receive CameraActivities Result In A Different Activity?

Mar 12, 2010

I hope the title says it all: I've got Activity A which fires up the Camera intent via:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, REQUEST_CAMERA);

After the picture is taken I can easily grab the picture in:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)

But I'd like to receive the result in Activity B in which the image can be edited.
Right now I'm receiving the result in Activity A and pass it over to Activity B which results in showing the GUI of Activity A for a short while:

Intent i = new Intent().setAction("DisplayJPEG");
i.setClass(this, EditImageActivity.class);
i.putExtra("IMAGE_URI", uri);
startActivityForResult(i, REQUEST_EDIT_IMAGE);

Of course, I will need the result from Activity B in Activity A after the image has been edited. But that should work with:

setResult(resultCode, data);

So there has to be a way to do what I need. Please point me into the right direction.

View 3 Replies View Related

Android :: Get Preview Size / Bad Result On Froyo Emulator

Aug 18, 2010

I was trying to use some of the new camera methods included in Froyo, i.e. setPreviewCallbackWithBuffer() & addCallbackBuffer(). In the documentation it's said you need first to create a buffer of appropriated size and use the addCallbackBuffer() method. The buffer size must be width * height * bits_per_pixel or otherwise you'll never receive a preview frame. To know the image size, you can ask to the camera about it's configuration. When I'm trying to configured the camera I use Camera.getParameters().getPreviewSize() the emulator says the size is 320*240, but with that size it didn't work on emulator. I used the old setPreviewCallback() and, in the onPreviewFrame(), I asked the size again. That time the size was 480*320. Then I hard- coded that values in the first code and everything worked. Now I'm afraid not only the emulator would have that behavior. Unfortunately I don't have any real device with Froyo and I can't try it. So, anyone have tried that methods in real devices? btw, are they really increasing the poor performance and frame rate?

View 2 Replies View Related

Android :: Analog Of Start Activity For Result For Service

Jul 14, 2010

Despite similar question was asked, I have differnet situation: My app consists mostly of a background Service. I want to start external activities and get results back.I see several options:Create dummy Activity and keep reference to it for using its startActivityForResult. This consumes quite a lot of memory, as we know. Use Broadcast Intents instead of Android's results infrastructure: ask client activities to broadcast their results before closing. This kind of breaks the idea and not so performance-efficient. Use Instrumentation directly - try to copy code from startActivityForResult into my Service. Use Service interfaces - serialize and add AIDL connection to the Intent for starting an Activity. In this case Activity should call Service directly instead of providing result. The third approach feels closer to Android for me, but I'm not sure if it's possible to do - Service does not have its Instrumentation, and default implementation seems to always return null.

View 1 Replies View Related

Android :: Get Result From Search Manager To Main Activity

Nov 18, 2010

Activity A is main activity. Whereas Activity B is SearcActivity (Search Manager). Activity B is List Activity, so whatever result comes, result is displayed in the list. Once user clicks on the list, I want to get that list selected item to be returned to ActivityA.What I did. Code...

View 3 Replies View Related

Android :: Application Not Showing Up Search Result In Market

Aug 26, 2010

I have uploaded an application in Android market. But when I search for the app the app do not appear in the autocomplete box which appears below the search box. For example, if I type "h" in the search box the autocomplete box will have the applications with "h". But in my case I need to type the complete name of the application.

View 1 Replies View Related

Android :: Result Disappeared When Mobile Orientation Is Changed / What To Do

Jun 21, 2010

In my application result displayed in Text view is disappeared when mobile orientation is changed,for this what can i do.i want my application in both modes means portrait and landscape.for this what can i do.

View 2 Replies View Related

Android :: Match Efficiently Result String With Various Options?

Jul 6, 2010

When you have a list activity and in onListItemClick() you need to obtain the selected item and then match it against various options, what is the efficient way to do it? switch case cannot be used since I want to match Strings. Is a very long if-else if ladder the only way to do it?

Basically the question is how to do something that normally would be done in switch statement with Strings.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved