0

i have this :

 @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 ";

        }

    }

i want to pass the value of the String urlCorrecta to the String VIDEO_IN_PIPELINE located in the class MainActivity.

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";

}

How can i take that String from the other class to this one?

thanks very much for reading.

1
  • 2
    Use Intent.putExtra for sending value to next Activity Commented Mar 1, 2015 at 16:15

3 Answers 3

1

To send the string from one activity,

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

To get String in ReceiverActivity

Intent intent = getIntent();
String str = intent.getExtra().getString("key");
Sign up to request clarification or add additional context in comments.

Comments

1

Use extras:

Intent intent = new Intent(this, LosGuayabos.class);
intent.putExtra("myString", myString);
startActivity(intent);

Then you just need to get the intent in your onCreate method:

String myString = getIntent().getExtras().getString("myString");

Comments

1

To pass it to another Activity, add it as an extra in your new Intent:

Intent intent = new Intent(this, MainActivity.class);
intent.putExtra("urlCorrecta", "souphttpsrc location=http://rax1.bsn.net/mjpg/video.mjpg?streamprofile=Balanced ! multipartdemux single-stream=true ! jpegdec ! autovideosink sync=false ");
startActivity(intent);

To retrieve it in MainActivity's onCreate():

String urlCorrecta = getIntent().getStringExtra("urlCorrecta");

Try this. This will work.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.