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.

Android :: How does service return result to activity


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 :: 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 :: 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 :: How Can Service Return A String Back To Activity?

Nov 11, 2010

I am new in Android. I encounter the following situation, I have a background running service, which will get a keep-updating string from a webpage, I need to show this keep-updating string in my UI through Activity, since this string is get from service, I am wondering, How can the service pass the string to Activity so that activity can render the string on UI.

View 5 Replies View Related

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?

View 8 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 : 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 : 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 :: Start An Activity And Return Back To Original Activity

Jan 26, 2009

I have an application with contains multiple activities. The main activity will start the others ( use startActivity() ) depends on user event, when an activity close, it calls finish() and return back to main activity. It appears to behavior like that.

However, the "problem" I see is main activity's onCreate function is called every time. I think the the main activity should be placed in the activity stack and simply push to front when others exit, therefore only onResume, onStart are called. Is there some flag I need to set or I misunderstand the activity behaviro?

In child activity, besides calling finish() or startActivity for main activity, what is other way to move main activity to front?

View 2 Replies View Related

Android :: How To Call Activity Wait For Sub-activity To Return & Proceed?

Apr 15, 2010

Experts: My MainActivity launches a SubActivity by calling: startActivityForResult(intent, REQ_CODE); The SubActivity shows a dialog that has two buttons: Yes, No For the dialog, I've the following code: public void onClick(DialogInterface dialog, int whichButton) {/* User clicked OK */setResult(DialogInterface. BUTTON_POSITIVE) ;finish();

View 2 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 : 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 :: How To End Child Activity And Return To Parent Activity?

Jul 25, 2010

I have a main screen with buttons to launch other subactivities. I have to press back button each time to go back to the main screen of my application. How do I finish a child activity and automatically return from the caller?

View 5 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 :: How To Pass Result From Activity Terminated By BACK Button?

Apr 20, 2010

I am trying to setResult after the BACK button was pressed. I call in onDestroy. So, how can I pass result from activity terminated by BACK button?

View 2 Replies View Related

Android : Forward Activity Result To Parent With SingleTop Launch Mode?

Jun 1, 2010

I have two activities: a MainListActivity, and a DetailViewActivity. DetailViewActivity is set with android:launchMode="singleTop".

When clicking an item in the "main list" activity, it launches the "detail view" activity via:

startActivityForResult(detailIntent, REQUEST_CODE_DETAIL);

If I then call setResult(RESULT_OK, resultData); and finish(); from within the Detail activity, that resultData is received by the "main list" activity's onActivityResult(..) method correctly.

However, if I implement a "see previous"/"see next" type of navigation within the Detail activity, and implement it using singleTop, that result no longer gets sent back to the initial activity:

Intent nextItemIntent = this.createIntent(nextId);
nextItemIntent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
startActivity(nextItemIntent);
// at this point, my DetailActivity's onNewIntent() method is called, and the new data is loaded properly

But from here, when I call setResult(..) and finish(), my MainList activity never receives the new/updated result. Anyone know what I'm doing wrong?

View 1 Replies View Related

Android : Default SMS Activity Result Code Coming As RESULT_CANCELED Even SMS Is Received Successfully

Jul 20, 2010

I am invoking the default SMS activity by using the following code-

intent = new Intent(Intent.ACTION_VIEW, Uri.parse("sms:")); intent.putExtra("sms_body", "SMSText"); startActivityForResult(intent, 11); //Here 11 is my request code

The SMS activity gets opened in emulator (5554), i type the number 5556 (device number of my second emulator) and click on "Send"

The SMS is received in second emulator(5556) successfully. I click back on 5554 (my SMS generating emulator )and come back to my application. I notice that the onActivityResult method is getting called successfully as desired.

When i check for the result code i get it as RESULT_CANCELED ( 0 ) instead of RESULT_OK (-1). The data is also coming as null.

View 3 Replies View Related

Android :: Network Service Need To Return Callback

Oct 6, 2010

if the service dies, and i know it can during request processing, it's an issue for me, first i've seen it, the process wont die until the net request returns (then the thread dies gracefully), unless kill -9 is used on the process... then i'm not sure what android does with the connections. I'm not sure what's the approach i should take here.(it will be true though even if this was a local thread and not a service)if i want the service to listen on a callback and call it once the network processing is done, i'm in a problem, no instances can be passed on using Intents.

So i need some other solutions, all the ones i though of sounds bad to me: A. use IBinder to get instance of the network service class then i can call one of it's methods and pass on an instance, this will work since they all run in the same process, BUT requires me to use Async way to get a Network instance which is not so suitable for me. B. Use static member in the Service i can access, then what to i need the service for ?. use intent to send parameters only to the service, the service will compose a Request out of it and put it in the queue, then once done will send a response using intent which will encapsulate the response (which might be long!) and will also contain the name of the calling class as a string so all the Receivers will know if it's for them or not - BIG overhead of encapsulating data in Intent and search in all the receivers for the right one to get the response.I don't want to use the service as a local running simple thread since i'm afraid if i'll run it in the root activity i will have to use static container so it will be visible in each activity and if the root will be destroyed for some reason it will take all the service with it, even if i start new task and the process is still alive.Anyone got some nice ideas on how to approach this thing ?

View 1 Replies View Related

Android :: Strange Error With Return String From Web Service

Aug 13, 2010

I have a strange issue. I am using KSOAP2 to create a soap request to a .net webservice. I do this in a few other places and everything works fine. The webservice basically queries a data base and takes the values from the data reader and creates a string. This string is then returned. When I run the webservice on my local machine(Without using android) it works fine. When I run it from the webserver (still not android) it works fine. When I call it from my phone however the line: String hazards = (String)envelope.getResponse().toString () ; //Get response from .net Web service Simply is filled with anyType{}. Now if I go to the webservice and I manually type in the contents from the database to represent what the string concatenation should be it works perfectly. The line: String hazards = (String)envelope.getResponse().toString(); //Get response from .net Web service Now returns the string value i need. Does anyone have any idea why this is happening or know a better place to ask this question?

View 4 Replies View Related

Android :: Return ArrayList From .net Web Service To Droid App Using KSoap?

Jun 9, 2010

My web service is returning quite a bit of data, so i'm storing it in an arraylist and returning that to my application. I don't know whether or not this is the preferred method or not. When the arraylist is returned and displayed in my application, it also displays the arraylists "anyType" section. I'm new to this whole process so i'm sure i'm missing something somewhere or going about this incorrectly. Can anyone point me in the right direction please?

View 2 Replies View Related

Android :: How To Test IBinder Object That Service Return On OnBind?

Apr 27, 2009

How to test my IBinder object that Service return on onBind ?

View 1 Replies View Related

Android :: Return To Root Activity After Task Cleared?

Jul 13, 2010

I have a app with 2 activities, A B A has a button that launches a new intent for B. When at B I press home, then launch app again, B is resumed with onResume(). But if after I press home, I use something like taskiller to clear tasks, then I launch app again, it still shows B, but onCreate() is called. What I want for the second situation is for the app to start A instead of B. How can that be done?

View 2 Replies View Related

Android :: Return To Original Activity After Call Ends?

Feb 28, 2009

I'm looking for a way to resume my activity (which makes phone call) after call ends by user. Currently after user ends a call, it always returns to the phone's native call-log screen instead of the activity that originated the call. Is there any way to prevent or customize this?

View 3 Replies View Related

Android :: How To Make Phone App Return To Last Open Activity?

Mar 14, 2010

Is it possible to configure an android app so that if a user has opened your app, launched numerous activities, then returns to the home screen and relaunches your app again, instead of going to the main activity they will instead be taken to the activity highest on the stack (the most recent activity in your app)?

View 2 Replies View Related

Android :: How To Return From Preference Screen To Main Activity?

Oct 14, 2010

I have one main activity and one preference Activity. On my first activity I call menu and go on preference Activity by calling startActivityForResult. Code...

View 1 Replies View Related

Android :: Return Back To The Parent Activity From Subactivity

Jun 14, 2010

My application supports twitter and needs to open browser for OAuth. When the user clicks the Share on Twitter button, the main activity will create another subactivity (TwitterActivity) to handle twitter authentication issues. Here is a flow graph showing how activities are invoked currently. Main is short for MainActivity and Twit for Twitter Activity. startActivity() OAuth intent OAuth callback finish()Main ---------------> Twit ------------> Browser --------------> Twit --------> Browser As you may notice, after the TwitterActivity calls finish() to stop, it will now return back to MainActivity, but Browser instead. How can I make it return back to MainActivity?

View 2 Replies View Related

Android :: Low Memory Cause Activity.getIntent() To Return Null?

Sep 10, 2009

As the title says? Or what situations can cause this method to return null? I would of thought it retained this object always.

View 2 Replies View Related

Android : Return To Call Activity - Once Button Is Pushed?

Jul 19, 2010

Newbie Question from an iPhone developer.

I have called the startActivity(intent) and the new activity loads. How do I go 'back' to the calling activity once a button is pushed. 'Popping' the activity off the stack basically.

View 2 Replies View Related







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