0

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.

whoknows
  • 296
  • 1
  • 4
  • 18
  • the empty content will be shown as nothing is there to draw , by the time condition checking is done – r4jiv007 Dec 19 '13 at 07:07
  • Can I do something to make it not visible? Skip it from loading? – whoknows Dec 19 '13 at 07:11
  • Set the theme for Activity as transparent, in that regard initially it will appear blank just like you want, once you checking is done load you view, I guess this might work. – Techfist Dec 19 '13 at 07:19
  • @Techfist It would seem to work at first. However, onBackpressed, it would navigate to the white screen. thus, transparent theme is like used only once. – whoknows Dec 19 '13 at 07:33
  • Just posting an solution for you – Techfist Dec 19 '13 at 07:40

2 Answers2

1

@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

Community
  • 1
  • 1
whoknows
  • 296
  • 1
  • 4
  • 18
0

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.

Techfist
  • 4,314
  • 6
  • 22
  • 32