Main - Java: Package Import Import Import Import Import Import Import Import
Main - Java: Package Import Import Import Import Import Import Import Import
to pass the
data across multiple program screens.
The putExtra method accepts many kinds of data, such as String, int, float, byte etc etc ..
It's much like what we do in an ASP.Net query string; we append it with payload and in the next page
we retrieve it with the same name. The same is here; we do putExtra, specifying the name of the variable
and we will retrieve it soon, for another intent.
Main.Java
package com.Program2;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class Main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Success.Java
package com.Program2;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class Success extends Activity
{
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.success);
TextView tv = (TextView) findViewById(R.id.textView1);
tv.setText("Welcome ,"+getIntent().getExtras().getString("username"));
}
}