gpt4 book ai didi

java - 如何将字符串传递给另一个类中的另一个字符串变量?

转载 作者:行者123 更新时间:2023-12-01 22:25:52 24 4
gpt4 key购买 nike

我有这个:

 @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

String urlCorrecta="";


//Si se escoge la posicion de el arreglo 0 abre la clase LasVegas
if (position == 0)
{
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
urlCorrecta = "souphttpsrc location=http://69.54.28.188:7878/mjpg/video.mjpg ! multipartdemux single-stream=true ! jpegdec ! autovideosink sync=false ";


}

//Si se escoge la posicion de el arreglo 1 abre la clase LosGuayabos
else if (position == 1)

{
Intent intent = new Intent(this, LosGuayabos.class);
startActivity(intent);

urlCorrecta = "souphttpsrc location=http://rax1.bsn.net/mjpg/video.mjpg?streamprofile=Balanced ! multipartdemux single-stream=true ! jpegdec ! autovideosink sync=false ";

}

//Si se escoge la posicion de el arreglo 2 abre la clase RegionalNorte
else if (position == 2)

{
Intent intent = new Intent(this, RegionalNorte.class);
startActivity(intent);

urlCorrecta = "souphttpsrc location=http://trackfield.webcam.oregonstate.edu/mjpg/video.mjpg ! multipartdemux single-stream=true ! jpegdec ! autovideosink sync=false ";
}


//Si se escoge la posicion de el arreglo 3 abre la clase RegionalSur
else if (position == 3)

{
Intent intent = new Intent(this, RegionalSur.class);
startActivity(intent);

urlCorrecta = "souphttpsrc location=http://wmccpinetop.axiscam.net/mjpg/video.mjpg ! multipartdemux single-stream=true ! jpegdec ! autovideosink sync=false ";

}

}

我想将字符串 urlCorreta 的值传递给位于 MainActivity 类中的字符串 VIDEO_IN_PIPELINE。

public class MainActivity extends ActionBarActivity implements SurfaceHolder.Callback{




private final String VIDEO_IN_PIPELINE = VALUE OF THE STRING urlCorrecta;
private final String HOST_IP = "192.168.1.167";

}

我如何将该字符串从另一个类转移到这个类?

非常感谢您的阅读。

最佳答案

要从一个 Activity 发送字符串,

Intent intent = new Intent(CurrentActivity.this, ReceiverActivity.class);
intent.puExtra("key","String Value");
startActivity(intent);

ReceiverActivity中获取字符串

Intent intent = getIntent();
String str = intent.getExtra().getString("key");

关于java - 如何将字符串传递给另一个类中的另一个字符串变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28795804/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com