I have the first intent, it starts the second intent. In the second intent, I get the values, and pass the value to the first content and close the second content. How can I do it?
            Asked
            
        
        
            Active
            
        
            Viewed 5,268 times
        
    2
            
            
        - 
                    1Possible duplicate of [How to send an object from one Android Activity to another using Intents?](https://stackoverflow.com/questions/2139134/how-to-send-an-object-from-one-android-activity-to-another-using-intents) – Nuwan Alawatta Jul 04 '18 at 23:33
- 
                    use `putExtra` or a `Bundle` object – rafaelc Jul 04 '18 at 23:38
2 Answers
1
            
            
        You can directly pass parameters to the intent when you create it. If you need to pass objects you need to implement Parcelable interface on the object you pass:
Intent i = new Intent(MyActivity.this, SecondActivity.class);
MyData j = new MyData();
i.putExtra("MyParameter", "Something");
i.putExtra("MyData", j); //only works if MyData implements Parcelable
startActivity(i);
In the second activity you can read your data:
Intent i = getIntent();
Bundle extras = i.getExtras();
if(extras.containsKey("MyParameter")) {
    String something = i.getStringExtra("MyParameter");
}
if(extras.containsKey("MyData")) {
    MyData otherthing = i.getParcelableExtra("MyData");
}
Hope this helps
 
    
    
        breakline
        
- 5,776
- 8
- 45
- 84
0
            
            
        try this
Passing the parameter to using intent i am passing the message like this
     Intent intent= new Intent(mContext,SuccessActivity.class);
     intent.putExtra("message",mContext.getString(R.string.success_sign_msg));
Get value using intent
     Intent intent=getIntent();
    success_msg_txt.setText(intent.getStringExtra("message"));
try this it helps you
 
    
    
        Android Geek
        
- 8,956
- 2
- 21
- 35