2
I’m trying to pass parameters a value from one screen to another, but in the other comes null, see:
Screen 1:
Intent telaWeb = new Intent(SegmentoView.this, ViewWeb.class);
Bundle bundleParametro = new Bundle();
telaWeb.putExtras(bundleParametro);
bundleParametro.putString("link", urlStr);
startActivity(telaWeb);
Screen 2:
Intent dadosRecebidos = getIntent();
if(dadosRecebidos != null){
Bundle parRecebidos = dadosRecebidos.getExtras();
if(parRecebidos != null) {
URL = parRecebidos.getString("link");
}
}
But the value is coming null. What is wrong?
tenta trocar de posicao... telaWeb.putExtras(bundleParametro); bundleParametro.putString("link", urlStr); troca por bundleParametro.putString("link", urlStr); telaWeb.putExtras(bundleParametro);
– Pedro Rangel
May I suggest something that will work, and narrow down your lines of code? put the value directly in Intent, telaWeb.putExtra("link", urlStr); and on screen 2 picks it up with getIntent(). getStringExtra("link")
– Flávio Silva