Get error when passing data using Intent
-
Any problem for my coding? Please help, thanks.
xml code
MyActivity.java
package com.example.user.myapplication;import android.app.Activity ;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;import static com.example.user.myapplication.R.*;
public class MyActivity extends Activity implements View.OnClickListener {
EditText mtext;
Button mbutton;[@Override](http://www.codeproject.com/Members/OverRide) protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(layout.activity\_my); mtext = (EditText)findViewById(id.medittext); mbutton = (Button)findViewById(id.btnsubmit); mbutton.setOnClickListener(this); } [@Override](http://www.codeproject.com/Members/OverRide) public void onClick(View v) { // Do something in response to button Intent intent = new Intent(this, ViewActivity.class); String message = mtext.getText().toString(); intent.putExtra("mtext",message); startActivity(intent); }
}
ViewActivity.java
package com.example.user.myapplication;import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
/** -
Any problem for my coding? Please help, thanks.
xml code
MyActivity.java
package com.example.user.myapplication;import android.app.Activity ;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;import static com.example.user.myapplication.R.*;
public class MyActivity extends Activity implements View.OnClickListener {
EditText mtext;
Button mbutton;[@Override](http://www.codeproject.com/Members/OverRide) protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(layout.activity\_my); mtext = (EditText)findViewById(id.medittext); mbutton = (Button)findViewById(id.btnsubmit); mbutton.setOnClickListener(this); } [@Override](http://www.codeproject.com/Members/OverRide) public void onClick(View v) { // Do something in response to button Intent intent = new Intent(this, ViewActivity.class); String message = mtext.getText().toString(); intent.putExtra("mtext",message); startActivity(intent); }
}
ViewActivity.java
package com.example.user.myapplication;import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
/**Can you just move your head slightly to the left? You're in the way of the hidden camera we've installed behind you, and we can't see the error details on your screen. :rolleyes: Oh, wait; we don't have a camera pointing at your screen. We also don't have remote access to your computer, nor telepathy. If you don't tell us what the error is, how do you think anyone will be able to fix it?
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Any problem for my coding? Please help, thanks.
xml code
MyActivity.java
package com.example.user.myapplication;import android.app.Activity ;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;import static com.example.user.myapplication.R.*;
public class MyActivity extends Activity implements View.OnClickListener {
EditText mtext;
Button mbutton;[@Override](http://www.codeproject.com/Members/OverRide) protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(layout.activity\_my); mtext = (EditText)findViewById(id.medittext); mbutton = (Button)findViewById(id.btnsubmit); mbutton.setOnClickListener(this); } [@Override](http://www.codeproject.com/Members/OverRide) public void onClick(View v) { // Do something in response to button Intent intent = new Intent(this, ViewActivity.class); String message = mtext.getText().toString(); intent.putExtra("mtext",message); startActivity(intent); }
}
ViewActivity.java
package com.example.user.myapplication;import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
/**No error checking, no
try
/catch
clauses, and the name of the extra differs between the put (mtext) and the get (abc). :rolleyes: How exactly are we supposed to help you? :confused:"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles