whoknows
whoknows

Reputation: 306

Android-Intent navigation to skip an intent/activity

Here is my scenario, on load of my main activity I have a checking that looks like this.

activity onCreate:

if(true) {
  navigate to other intent
}

setContentView(layout);

//..rest of the code.

You see. If my condition is met, I want to navigate to other intent. Otherwise, I load the content view of the current activity. However, during implementation, an empty content view shows first before the "other intent".

Do you have any recommendation on how I can immediately load to the "other intent"? Thanks.

Upvotes: 0

Views: 266

Answers (2)

whoknows
whoknows

Reputation: 306

@Techfist, thanks I've set my default theme to transparent. so, my previous condition was met. However, in this scenario:

if(false) {
   navigate to other intent
}

setContentView(layout);

//..rest of the code.

my activity was shrunk. so I added this. Change Activity's theme programmatically

Upvotes: 1

Techfist
Techfist

Reputation: 4344

Try this:

  1. Set the default theme of your first activity to transparent,
  2. In this way when you condition is met, you will see backgound as transparent mimicking scenario you want, but remeber still activty was launched so it will remain on stack, hence if you press back from second activity first will be popped up disturbing your scenario again, so to tackle this, when you launch second activity upon condition dont forget to finish it, hence when you press back from second it wont return to first and directly exit.
  3. Is condition is not met simply proceed by setting up content view

Hope it help, if you face probelm again then try starting second activity for result, and when second finishes, finist first as well on receive result.

Upvotes: 0

Related Questions