Android :: How To End Child Activity And Return To Parent Activity?
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 Complete Thread with Replies
Sponsored Links:
Related Forum Messages:
Android :: Finish Parent Activity From Child?
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 Replies!
View Related
Android :: Parent And Child Activity OnCreate?
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 Replies!
View Related
Android :: Return Back To The Parent Activity From Subactivity
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 Replies!
View Related
Android :: FinishFromChild And OnActivityResult Not Firing When Child Starts Activity Of Same Type As Parent
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 Replies!
View Related
Android :: Start An Activity And Return Back To Original Activity
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 Replies!
View Related
Android :: BringtoFront The Parent Activity?
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 Replies!
View Related
Android :: Activity That Does Not Fill The Parent Screen
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 Replies!
View Related
Android :: Picking A Contact And Returning To The Parent Activity
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 Replies!
View Related
Android :: Detect If A View's Parent Activity Is Paused
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 Replies!
View Related
Android : Lifetime Of Background Parent Activity After StartActivityForResult()?
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 Replies!
View Related
Android :: Pass Data To A Child Activity
I wounder if there is some possible to know from which parent Iam coming from in the child so I can do different stuff depending on who the parent is of the activity.This is how Iam going over to the child. But I don't know how to handle this in the child to check who is the parent. The above code is used on one of the parents,, is there somehow I can use "EQ_CODE_SELECT_LOCATION"? Also I wounder how is possible to send data to a child activity?
View Replies!
View Related
Android :: Child Activity Lifetime In Background
I have next problem, I have got parent activity and few sub- activities, if app goes to the background by pressed HOME button for long time, all children will be killed, and my app restart from parent activity. For example: A1 - parent, A2,A3,A4 - sub-activities. A1-->A2-- >A3(top), from A3 I go to the background (HOME). wait 30-40 min and
View Replies!
View Related
Android :: SingleInstance Of The Activity And Relay Information Back To Parent?
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 Replies!
View Related
Android :: Create A Single Class Which Can Be Parent For Every Type Of Activity?
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 Replies!
View Related
Android : Forward Activity Result To Parent With SingleTop Launch Mode?
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 Replies!
View Related
Android :: How To Receive Signals In An Activity To Kill Child Process?
My application calls Runtime.exec() to launch an executable in a separate process at start up time. I would like this child process to get killed when parent activity exits. Now I can use onDestroy() to handle regular cases, but not "Force quit", shutdowns from DDMS, or kill from the console since those don't run onDestroy(). The addShutdownHandler() does not seem to be invoked in these cases either. Is there any other hook or signal handler that informs my activity that it's about to get terminated? As an alternative is there a way to have the system automatically kill the child process when the parent die?
View Replies!
View Related
Android : Child Activity Exit By Unexpected Exception - OnActivityResult - Is Not Called
I have faced with issue about startActivityForResult() and onActivityResult(). If child activity started by the startActivityForResult() exit by unexpected exception the onActivityResult() is not called and I have no any ideas how can I handle this to get application working in a fail-safe manner ? When my code runs child activity with startActivityForResult() it awaits until onActivityResult() will be invoked to get working further, but onActivityResult() is not calling and my code is "hang- up" (logically). So the question is how can I handle all possible ways the child activity is finished (normally and by unexpected exception) to get fail-safe code ? I have check the documentation for this issue but have found nothing relating issue.
View Replies!
View Related
Android :: How Does Service Return Result To Activity
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 Replies!
View Related
Android :: Scrollable Parent With ListView Child
I know it's considered taboo to place a ListView inside a scrolling container, so is there any "proper" way to accomplish scrolling of a container that has a ListView child in it? An example layout would look something like: Header --- "Sub" header --- ListView with list items --- Footer Header and Footer need to remain static on the screen, and the middle content (Subheader and ListView) should scroll between them. I can't have just the ListView scrollable, because the subheader takes up too much space. As it is currently, the Header comes from an <include />, the Subheader contains several views including an Image and some text, and the ListView (actually part of a ViewFlipper) would contain an indeterminate number of items. The Footer has a couple buttons/tabs that are used to control the ViewFlipper (only one of the views in the flipper is a ListView). The only way I can think of to accomplish this efficiently would be to place the Subheader inside the ListView as the first item -- is there any better way?
View Replies!
View Related
Android :: Return To Root Activity After Task Cleared?
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 Replies!
View Related
Android :: How Can Service Return A String Back To Activity?
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 Replies!
View Related
Android : Return A Result (startActivityForResult) From A TabHost Activity?
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 Replies!
View Related
Android :: How Do I Return To Calling Activity If User Presses Back?
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 Replies!
View Related
Android :: How To Launch An Activity From A Widget And Return To Home Screen
I have a widget that when clicked opens an activity from same app as the widget. When the activity is closed/dismissed via a button, the user will see the full app window IF the app was previously open/in memory. Is there a way for the activity to finish and return to the home screen and not to an existing instance of the app? Intent i = new Intent(this,RateIt.class); i.putExtra("com.sporadicsoftware.NetQ.movie_id",aMovie.title_id); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET|Intent.FLAG_ACTIVITY_NO_HISTORY|Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_UPDATE_CURRENT); updateViews.setOnClickPendingIntent(R.id.movie_one_title, pendingIntent);
View Replies!
View Related
Android :: Dialog Activity To Return Before Continuing Executing Of Main Thread
How would I force the current thread to wait until another has finished before continuing. In my program the user selects a MODE from an AlertDialog, I want to halt executing of the program before continuing as the mode holds important configuration for the gameplay. new AlertDialog.Builder(this) .setItems(R.array.game_modes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: setMode(TRAINING_MODE); case 1: setMode(QUIZ_MODE); default: setMode(TRAINING_MODE); break; ............ //continue loading the rest of onCreate(); contineOnCreate(); } }) .create().show(); If this is impossible can anyone give a possible solution?
View Replies!
View Related
Android :: Return To Previous Activity Without Calling Finish() / Save This Information?
I have an android application with a LOT of activities, think of something like a book where every page is a new activity. The user can make changes in each activity, for example highlight certain texts with different colored markers etc. and it's crucial that I'll remember this information as long as the application stays alive (and I don't want/need to remember any of this when it's not). As I understand the best mechanism for storing this kind of information is via onSaveInstanceState(Bundle outState) and onCreate(Bundle)/onRestoreInstanceState(Bundle) rather than lets say, the Preferences mechanism. My only problem is that the user can navigate backwards to previous pages (Activities) and the only way i know of achieving this is by calling finish() which of course kills the current activity without calling onSaveInstanceState(Bundle outState) and even if it did call it, the next time I would launch an activity representing that page it would be an entirely new instance. So my question is: Is there a way to go back to the previous activity without calling finish()? or, is there a better way to save this information? maybe through static variables?
View Replies!
View Related
Android :: Inherit Parent Style And Set Background For Non- Focused Enabled Child Item?
I'm using ExpandableListView in my app and one of the complains is that when expanded it's hard to visually distinguish where the child item ends and next group item begins. So I would like to change background of the child list item to the different shade. Brutal attempts that I've made so far were based on directly changing background color and text of the elements inside the child view item but that leads to loss of hovers and highlights. So my question is - what is a good strategy to achieve the above? I tried styles and selectors but what really bums me out - that if I change one thing then I need to add selectors for all combinations of focus/enabled etc. when all I'm trying to do it to overwrite a single thing. Is there a way to inherit parent style and set just a background for non- focused, enabled child item?
View Replies!
View Related
Android :: Child Activity Does Not "finish()" Correctly
I have a ListActivity I display from a parent activity. When the user selects the desired item from the list it supposed to return to the parent activity. Only when I call finish, the app goes away (doesn't quit) and displays the Android Home page. If I debug, the application doesn't die, it just sits on an MessageQueue.Wait(). I have a break point right before the finish() call and one in the first line of the OnActivityResult. When I press continue from the first, I never see the second on in onActivityResult. I have other child activities in my app that don't display this problem. However this is the only ListActivity I have that I am trying to return from. I do call finish from onListItemClick. I'm wondering if that is not allowed since that is responding to a view event. However if I don't do it here, how can I get back to the parent activity. Below is the code snippet of my finish method. CODE:...................
View Replies!
View Related
Android :: Instance Variable Of Activity Not Being Set OnPostExecute Of AsyncTask - Return Data From AsyncTask
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 Replies!
View Related
|