android - Start an Activity with a parameter -


i'm new on android development.

i want create , start activity show information game. show information need gameid.

how can pass game id activity? game id absolutely necessary don't want create or start activity if doesn't have id.

it's activity has got one constructor 1 parameter.

how can that?

thanks.

put int id new intent.

intent intent = new intent(firstactivity.this, secondactivity.class); bundle b = new bundle(); b.putint("key", 1); //your id intent.putextras(b); //put id next intent startactivity(intent); finish(); 

then grab id in new activity:

bundle b = getintent().getextras(); int value = -1; // or other values if(b != null)     value = b.getint("key"); 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -