yes i have given the request code
On Thu, Mar 1, 2012 at 1:13 PM, MOHANAKRISHNAN <[email protected]> wrote:
> import android.app.Activity;
> import android.os.Bundle;
> import android.util.Log;
> import android.view.Window;
> import android.view.KeyEvent;
> import android.widget.Toast;
> import android.content.Intent;
> public class MainActivity extends Activity {
> String tag = “Events”;
> int request_Code = 1;
> /** Called when the activity is first created. */
> @Override
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> //---hides the title bar---
> //requestWindowFeature(Window.FEATURE_NO_TITLE);
> setContentView(R.layout.main);
> Log.d(tag, “In the onCreate() event”);
> }
> public boolean onKeyDown(int keyCode, KeyEvent event)
> {
> if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER)
> {
> //startActivity(new Intent(“net.learn2develop.ACTIVITY2”));
> //startActivity(new Intent(this, Activity2.class));
> startActivityForResult(new Intent(
> “net.learn2develop.ACTIVITY2”),
> request_Code);
> }
> return false;
> }
> public void onActivityResult(int requestCode, int resultCode, Intent data)
> {
> if (requestCode == request_Code) {
> if (resultCode == RESULT_OK) {
> Toast.makeText(this,data.getData().toString(),
> Toast.LENGTH_SHORT).show();
> }
> }
> }
>
> activity 2
>
> public class Activity2 extends Activity {
> @Override
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.activity2);
> //---get the OK button---
> Button btn = (Button) findViewById(R.id.btn_OK);
> //---event handler for the OK button---
> btn.setOnClickListener(new View.OnClickListener()
> {
> public void onClick(View view) {
> Intent data = new Intent();
> //---get the EditText view---
> EditText txt_username =
> (EditText) findViewById(R.id.txt_username);
> //---set the data to pass back---
> data.setData(Uri.parse(
> txt_username.getText().toString()));
> setResult(RESULT_OK, data);
> //---closes the activity---
> finish();
> }
> });
> }
> }
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
--
Regards,
Vani Reddy
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en