Start an new Activity Intent with a parameter Android example

putString(), putBoolean(), putInt() etc.¨
How we can start an activity programmatically.

// MainActivity.java
//  myButton.setOnClickListener
Intent binary = new Intent(getApplicationContext(),Calculate.class);
	Bundle b = new Bundle();
	b.putString("prvni_label", "Decimal");
	b.putString("druhy_label", "Binary");
	b.putString("mode", "binary_to_decimal");
        binary.putExtras(b);
	startActivityForResult(binary, 0);
 
// in Calculate.java onCreate
 
   TextView mTextView1 = (TextView)findViewById(R.id.textView1);
   TextView mTextView2 = (TextView)findViewById(R.id.textView2);    
     Bundle _bundle = getIntent().getExtras();
		mTextView1.setText(_bundle.getString("prvni_label"));
		mTextView2.setText(_bundle.getString("druhy_label"));
//.................. HOW OPEN START NEW ACTIVITY WITHOUT A PARAMETER .........................
 
startActivity(new Intent(ThisActivity.this, NewActivity.class));
This entry was posted in Android Examples Code and tagged , . Bookmark the permalink.


Comments are closed.



4,676 views