Loadeed
Loadeed

Reputation: 567

Android activity glitch

I call one activity with Intent. In that activity (method create) I check for some parameters and call another - third activity. Before that third activity loads, I can see view of that second activity for a few milliseconds. I don't load view in second activity.

Upvotes: 1

Views: 262

Answers (3)

lordl
lordl

Reputation: 471

Use startActivityForResult to start the third activity (from the onCreate-method), even though you don't need the result. This will keep the second activity window from showing.

Upvotes: 1

Jeremy Edwards
Jeremy Edwards

Reputation: 14740

The problem here really is that the first activity should call the third activity directly. Just extract the logic that determines the 2nd activity by-pass to a separate class and call that instead of the 2nd activity.

Well made activities are actually supposed to be very lightweight mainly plumbing stuff like loading parameters and the root view hierarchy and routing events to fragments. If you can't do that (refactor is too difficult) try disabling the activity transitions via the Activity.overridePendingTransition(int enterAnim,int exitAnim) method.

Upvotes: 0

android developer
android developer

Reputation: 116000

call the "setContentView" inside the seconds activity only (once and) when you wish to show the content of the second activity.

also , if you call finish on the seconds activity when you start the third one , remember to return from the function and not continue with the initialization (and the call of "setContentView") .

Upvotes: 0

Related Questions