I have an Activity A
User clicks on a button in Activity A, it starts Activity B in library
The user interacts with Activity B in library and on clicking a Linkedin login button in it,
how to pass control to Activity A so it can do the login related logic and then return to Activity B.
i assume that.. Activity A -> Activity B, then click Login -> Activity A..
all you need to do is.. use LinkedIn Callback method after registration. inside that method, Intent to Activity A..
I don't know what the library is, but I presume that it should return some result. Try with startActivityForResult method inside Activity A.
For more details please read Getting result from an Activity
Related
When user click on a notification, I set up a backstack of Activities A -> B, where B is on top and shown to user. I would like the lifecycles of Activity A to run, so that when user presses back button and comes to Activity A, it is already ready. What could I do to achieve this?
This cannot be possible as android will not allow us to do that, the only way I can see you can achieve this by doing your Activity A operation inside your Activity B And provide those details to Activity A when the user pressed back button.
Note: If you are showing any kind of list on Activity A or doing similar kind of work, you can have one Singleton Class where you can get your data in Activity B which required by Activity A, and provide same data to Activity A when the user pressed back button.
You should open the activity as normal but then put this line of code in the OnCreate() method to bring to the back.
moveTaskToBack(true);
I have 2 activities A and B
activity A contains a button to call activity B and A also contains a listview.
activity B contains some checkboxes and a close Button
After I click to close activity B I would like to update activity A's listview. What method do you think is good for me to follow now ?
To achieve your functionality, you need to launch activity B using .startActivityForResult() and override the onActivityResult() method to do all the processing you need to do when B has been terminated.
In my android apps i have four activity A->B->C->D and in every activity i call web service then update the list-view and other element from the server so suppose i did delete some data from the database for Activity A and if user access the Activity B and he press the back button then Activity A should be refreshed. I did override onResume method and check the data is updated or not but didn't worked. I also tried another way but not achieve my goal.
my Activity structure is like a following
Class A Is Fragment which is having two tab and each tab contain listview
Class B Is Activity
Class C Is Activity
Class D Is Activity
I don't understand how to call web service again when press the back button and how to update fragment and activity when user press the back button. Please anybody suggest me some answer.
Thanks in advance
you can override the OnBackPressed-method. check the top-answer on that link!!
Android: Proper Way to use onBackPressed() with Toast
Start activity B from activity A with "startActivityForResult" instead of "startActivity".
In activity B you defaultly return RESULT_CANCELED -> so setResult(RESULT_CANCELED). Only when activity B is finished on purpose you return RESULT_OK.
In activity A you then just need to implement onActivityResult(). Depending on the result returned from activity B you can then do specific stuff in activity A, in your case refresh something.
Here is an example: http://www.vogella.com/articles/AndroidIntent/#usingintents_sub
I'm developing a android aplication using login activity how main activity. When the user login the aplication show other activity (intent), but if the user push back button the application show the main activity with the login. ¿How lock login activity after make login in the aplication?
Thank you!
If you want to prevent the user from returning to the login activity, there are two approaches:
After successful login, the login activity can simply call finish() after starting the main activity. This will end the login activity so when the user presses the back button, the app simply finishes.
Have the main activity be the launch activity for the app. In onCreate, you can call startActivityForResult() and launch your login activity. When the login activity finishes, the main activity can either proceed normally if the login was successful, or finish() (or operate in a restricted mode) if the user failed to log in.
Use
finish();
after you switch to another class.
Example :
Intent newIntent = new Intent (firstActivity.this, afterLogin.class)
startActivity(newIntent);
finish();
am having a two activities that interact.
activity A picks input values and sends to activity B for the user to confirm input before submitting. activity B should allow the user to go back to activity A to edit input values if required or submit the values if they are ok. If user submits values, activity A should be finished and if he edits, then he goes back to activity A.
I have used startActivityForResult() and setResult() methods to kill the activity A when the user submits the values that has worked perfectly, but when i click the edit button to return to activity A, it call the activity A using a new Intent, and subsequently, it starts the activity A, yet previously started activity A is still running . what i want is to resume the activity A where it was left with the existing values before activity B started on click of the back button. How do i achieve this?? Your assistance is highly appreciated
Call finish() in Activity B when you need to edit. There is no need to fire an intent that creates new instance of Activity A. It will resume Activity A.