Peter
Peter

Reputation: 2500

How to finish activity from other activity

im looking a way to finish first activity from other

First activity it's my splashscreen. i want to show him while second activity building../downloading datas and interface, and in asynctask from second activity i want to finish first activity. i dont need simple way with delay. It's possible ?

Upvotes: 1

Views: 145

Answers (4)

pratsJ
pratsJ

Reputation: 3443

Since you need to start asynctask of second activity from the beginning and meanwhile till the data downloading finishes, I am guessing you want to show the splash screen.

You have two activities, splash screen activity and main activity.

First start your application with main activity instead of splash screen activity. Inside main activity, start your asynctask and call splash screen activity as child activity using startActivityForResult (Intent intent, int requestCode). Which will open your splash screen activity as child activity. As soon as your background processing finishes, you can close your splash screen activity using finishActivity (int requestCode).

Let me know if it worked out for you.

Upvotes: 0

Bracadabra
Bracadabra

Reputation: 3659

I see several options:

  1. Use fragments and load data in activity, when data loaded replace splash with actual data.
  2. Send intent(or event through EventBus) from second activity and catch it with BroadcastReceiver in first activity.

Upvotes: 1

vishal jangid
vishal jangid

Reputation: 3025

<activity
    android:name="package name with class"
    android:noHistory="true">

Upvotes: 0

Igor Morais
Igor Morais

Reputation: 645

Try android:noHistory="true" in your splash screen, you can set this in manifest file.

Like this:

<activity
        android:name=".package.SplashScreen"
        android:noHistory="true"
        ...
</activity>

See more here.

Upvotes: 5

Related Questions