Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wait for intent to finish before continuing with the activities

I illustrate my problem, I selected an application that performs a series of operations in quick succession the touch of a button. each action is represented by an intent to perform a load of an app in the Market or an installation of an external apk.

currently my app does it all in quick succession, but most often give error especially when the intent become many (more than 8) so I wanted to rewrite the code so that:

  • I get a toast,
  • the first launch of intent,
  • the main activity is paused,
  • the term installation or download,
  • with the back button returns me to the main app
  • that shows me the second toast,
  • and start the second intent,
  • etc.. etc..

then there is a way to wait for the end of a first intent to continue?

like image 247
r1si Avatar asked Jan 21 '12 10:01

r1si


People also ask

How do you finish an activity after Intent?

On Clicking the back button from the New Activity, the finish() method is called and the activity destroys and returns to the home screen.

How do you Intent an activity?

1.2. To start an activity, use the method startActivity(intent) . This method is defined on the Context object which Activity extends. The following code demonstrates how you can start another activity via an intent. # Start the activity connect to the # specified class Intent i = new Intent(this, ActivityTwo.

What type of Intent is used when you start an activity?

You'll typically use an explicit intent to start a component in your own app, because you know the class name of the activity or service you want to start. For example, you might start a new activity within your app in response to a user action, or start a service to download a file in the background.


1 Answers

Use startActivityForResult() to start your load / installation or whatever. Handle the back button event in the started activity to abort the running action.

When your sub-activity has completed you may evaluate the result in onActivityResult() in your main activity.

See here for more info: http://developer.android.com/reference/android/app/Activity.html

like image 126
Stefan Avatar answered Oct 20 '22 09:10

Stefan