I have main activity which contains few radio buttons. Their is one button named config.
What I want to do is on clicking config new activity will start and selected radio button text will be displayed.
But when I click on config application is forced closing.I am not able to figure out the bug.
I have gone through following links to learn about intent
1) http://www.androidaspect.com/2012/07/passing-data-using-intent-object.html
2) http://www.androidaspect.com/2012/02/how-to-start-new-activity-using-intent.html
Here is the code for onclick from main activity:
configbtn.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View arg0) {
//Toast.makeText(getApplicationContext(), "You have clicked on 'Config'...", Toast.LENGTH_LONG).show();
if(!mode.equals(""))
{
Intent i = new Intent("com.av.android.profiles.configActivity");
Bundle myBundle = new Bundle();
myBundle.putString("promode",mode);
i.putExtras(myBundle);
startActivityForResult(i, 1);
}
else
{
Toast.makeText(getApplicationContext(), "Please select profile mode to config...!", Toast.LENGTH_LONG).show();
}
}});
Code for Second Activity :
public class configActivity extends Activity{
Bundle myBundle1 = new Bundle();
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.config);
String myName = null;
Bundle extras = getIntent().getExtras();
if(extras != null)
{
myName = extras.getString("promode");
}
TextView tvData = (TextView) findViewById(R.id.tvData);
tvData.setText(myName);
}}
Thanks in advance
Try
Declare
configActivityin manifest file.and use
myName = extras.getString("promode");