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
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
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
May 8, 2009
I basically have three activities X, Y, Z and I want only one instance of each but I want control over the navigation and I can't do that by putting all three activities in one task because of the stack structure.
Here is a scenario, from X I launch Y given a certain "id" which correspondence to specific data in the DB, Y inflates and populates it's views, then I go back to X and launch Y again with a different "id" in the intent, I don't want the overhead of launching the activity and inflating the views again, anyone know how to do this?
I tried using singleInstance, but the problem is that I can't send the result code back to an activity in a different task.
View 4 Replies
View Related
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
Aug 4, 2010
My MAIN activity is spawning a child activity that contains a ListView. While this ListView is being populated (through an AsyncTask), an indeterminate progress bar is shown.However, assuming that I am an impatient user and I press the BACK button, the progress bar is cancelled but I am left with a blank screen. I have to press BACK one more time to go back to the MAIN activity.I would like the app to go back directly to the MAIN activity by pressing BACK only once. Can somebody point me in the right direction? I am thinking I should call finish() somewhere but I don't know where to put it.
View 3 Replies
View Related
May 5, 2010
does anyone know how to get result from subactivity to MainActivity without close the subactivity? i know the usual way is using method called "startActivityForResult (Intent intent, int requestCode)" and inside the subActivity set the result 1st before finish(); method
setResult(requestCode,intent); finish(); then the function called "protected void onActivityResult(int requestCode, int resultCode, Intent data)" which is inside main activity will get the result. BUT... by using that way, it will close my sub activity and the system will go back to main activity...........
View 2 Replies
View Related
Mar 29, 2010
I still have a problem to develop a convenient app to the user. because i am struggling using the activities, intent and intent filters. www.developer.android.com/reference not fit for me to understand these things. can you suggest me a fine example code or tutorial to understand how these things are getting worked.
View 1 Replies
View Related
Jun 2, 2009
How can I differentiate an android Activity from a SubActivity programatically?
Is there any api for that?
View 1 Replies
View Related
May 17, 2010
I have three activities in my android app. First activity is main application screen which gives option to open second screen containing second activity. But when I click on the button on second activity which was supposed to open third activity screen.
I get "Application has stopped unexpectedly" error.
CODE:.................
View 3 Replies
View Related
Apr 7, 2010
Can someone tell if why when starting an activity with startActivity(intent) , calling getParent() in onCreate() of the new created activity returns a nul ?
Also how could I obtain the parent of an activity created in such a way ? Can a reference of the activity below the current activity in the activity stack be obtained ?
View 2 Replies
View Related
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
Sep 7, 2010
As we know, startActivityForResult() used to get a result for a task from parent activity. Here when we click the setResult(). It returns the result to the parent Activity.
Child Activity means it should maintain the persistent state. That is when the users clicks a button on the child activity. It do not finishes that activity and show the Parent Activity. And again i may go to the child activity from parent activity. If the child does not exists it starts a new child activity else it should show the existing child activity with persistent content.
Simply said, my parent Activity starts a new Child Activity. Now both Activities should be alive. How to call the Parent Activity without finishing the child Activity(in other words, How to BringtoFront the parent Activity)? For this scenario,
you can not use startActivity(). Because it creates a new Activity Instance. Not Existing Parent Activity
you can not use startActivityForResult(). Because it finishes the child Activity Instance.
View 2 Replies
View Related
Dec 29, 2009
I am using ViewFlipper for my application. I trying to make it.when user pressed on escape (back) button, it would be back to parent Layout.
View 3 Replies
View Related
Mar 30, 2010
My child activity X is called from Parent activity P through startActivity(intent). I want to close P when X called its finish() method. I override a method finishFromChild(Activity child) in P and called finish() in it. But this functions (finishFromChild(Activity child)) is not being called after X finish() Is it a known bug or I am missing some thing? I googled and also searched the groups but no help.
An alternative could be... using StartActivityForResult() and a "fake" onActivityResult, where I can finish the parent activity, but this way is quite bad, i think...
I prefer the first one, if it would work....
View 3 Replies
View Related
Dec 14, 2009
Any idea why this doesn't create an activity that looks like a popup instead of an activity that completely fills the screen?
CODE:.............
I assumed that I only needed to set the layout height and layout width to something other than "fill_parent", but it still shows up as a black screen that completely fills the screen.
Ultimately, I simply want to create a popup, but I do not want to use an AlertDialog. Is this possible?
View 2 Replies
View Related
Jul 2, 2010
I have a parent activity, and a child activity that extends the parent activity. When the parent starts the child activity,
Which onCreate gets executed first? The child's or parent's?
There is a particular variable I am setting in the Child activity's onCreate method, and right now, it looks like it takes a while to get to the Child activity's onCreate, and so the methods in the Parent are reporting an empty variable. Whereas when I make the Parent sleep for a while, it reports the correct variable.
CODE:............
So, basically, even after the Parent starts the Child, it still returns "Parent Value", but when I have the thread sleep, it return "Child Value".
View 1 Replies
View Related
Jun 28, 2010
When we want to pass data from an activity to a sub activity we use the is there any event handler that handles this?
View 1 Replies
View Related
Nov 8, 2010
I want to open new child activity in the parent LinearLayout. Just similar like Tabs.
View 1 Replies
View Related
Jan 28, 2010
I wish to re-use the Contacts application in a way to enable the user to pick a contact and return it to the parent activity (my application's activity).
For achieving this, I want to inquire about the kind of Intent that will be needed to launch the contacts application.
Intent i = new Intent(Intent.ACTION_GET_CONTENT, ?); startActivityForResult(.....);
What should be the second argument here ?
In the deprecated Contacts API, I could use the following snippet, but not sure about ContactsContract:
Intent i= new Intent(Intent.ACTION_GET_CONTENT,People.CONTENT_URI); startActivityForResult(i, reqCode);
View 3 Replies
View Related
Jun 30, 2010
I want to do some cleanup in a view when the activity is being destroyed. Is there any way to get a callback in the View when the activity is being destroyed? I tried using onDetachedFromWindow, but I'm not sure whether it is correct thing to do.
View 1 Replies
View Related
Jun 20, 2010
In one of my Activities I have a ListView that displays a list of locations. For each list item I want a little arrow icon that points in the direction of the corresponding location. I implemented this icon by extending ImageView. This custom View has a listener that reacts to changes of the device's orientation by rotating the icon image accordingly. I register the listener in the onAttachedToWindow() method and unregister it in onDetachedFromWindow(). This kind of works but the problem is that onDetachedFromWindow() sometimes gets called only a long time after the containing Activity has paused. Also, the whole layout overall seems a little hacky. So my question is: Is there a proper way to unregister the listeners or would you implement this in a completely different way to begin with?
View 1 Replies
View Related
Jul 19, 2010
Is there an exception in the lifetime rules for a parent activity that's in the background after invoking startActivityForResult()? From my understanding, in low memory scenarios, the background activities are killed before the foreground. Does this rule still apply even if the background activity started the foreground one for the purpose of obtaining some result?
In this case, I think it would make sense for the foreground child activity to get killed first or to equalize the lifetime of the parent and child.
View 5 Replies
View Related
Aug 5, 2010
The order is:
A: startActivityForResult( B ) B: <dostuff>, call finish() A: onCreate <---- what's this all about A: onActivityResult
This happens for a tiny minority of users. I havn't been able to reproduce or find any common elements. A is the launch activity.
CODE:..............
View 7 Replies
View Related
Oct 7, 2010
I wish to have a single class which all of my Activity classes extend. I have ListActivities, Activities, MapActivities, TabActivities, etc in my App.
I have many of these different activities in my app, ~12 activities. I want each of them to have the methods which are in the parent class.
Right now, i have created 4 parent activity classes which are extended from a certain activity depending on their type(ListActivity, Activity, MapActivity, TabActivity)
I am creating a lot of redundant code - each of the 4 parent activities has almost identical code, in exception for what class activity it extends.
Here is an example that may clarify what my problem is:
I have an Activity: MenuScreen which extends BaseListActivity BaseListActivity extends ListActivity BaseListActivity contains methods and fields which i want all my activities to have access to I have another Activity: HomeScreen which extends BaseActivity BaseActivity extends Activity BaseActivity contains the same methods and fields which are in my other Base[<type>]Activity classes(such as BaseListActivity)
These methods/fields are copy-pasted to all my Base[<type>]Activity, and seems awfully redundant to me.
Can i create a master activity class which all types of Activity classes can use as its parent? if not, am i stuck with copy and pasting this code and feeling gross/dirty about it?
View 2 Replies
View Related
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
Jun 8, 2010
I have an application, which (for the sake of simplicity) has two types of activities - Overview and DetailView. The Overview activity shows a list of steps and allows the user to start a DetailView activity corresponding to the step chosen.
In the DetailView activity, the user can start another Overview, which shows different steps than the ones in the parent of the current DetailView.
In the Overview, DetailView is started by using startActivityForResult (). In the DetailView, when the user decides to start a second Overview, I call setResult () and finish () and then start the new Overview. In this scenario, onActivityResult () and finishFromChild () do not fire. Instead, they fire when the parent finishes (?).
Code from Overview:
CODE:....
Code from DetailView:
CODE:..........................
View 1 Replies
View Related
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
Nov 4, 2010
This is what I'm trying to support. Can this be done?
a) User is an Activity A in my app. b) The user is taken to the native dialer when he chooses a particular action in my Activity c) User presses the back key d) Taken to homescreen
Is there a way I can change it, so the back key press returns him to my app, instead of native homescreen?
View 14 Replies
View Related
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