Pease help me with my code.
When i click any button, button1, button2 or button3 opens new activity, but layout is empty, without any text's and others.
Code of activity from calling the new activity:
package com.novator.inweld;
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;
public class TentsCatalog extends Activity implements OnClickListener
{
private Button button1;
private Button button2;
private Button button3;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.tents_catalog);
button1 = (Button)findViewById(R.id.button1);
button2 = (Button)findViewById(R.id.button2);
button3 = (Button)findViewById(R.id.button3);
button1.setOnClickListener(this);
button2.setOnClickListener(this);
button3.setOnClickListener(this);
}
#Override
public void onClick(View view)
{
if(view == button1)
{
Intent intent = new Intent(this, TentPage.class);
intent.putExtra("tentId", "1");
startActivity(intent);
}
if(view == button2)
{
Intent intent = new Intent(this, TentPage.class);
intent.putExtra("tentId", "2");
startActivity(intent);
}
if(view == button3)
{
Intent intent = new Intent(this, TentPage.class);
intent.putExtra("tentId", "3");
startActivity(intent);
}
}
}
Code of my new activity:
package com.novator.inweld;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class TentPage extends Activity
{
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Intent intent= getIntent();
String tentId = intent.getStringExtra("tentId");
if(tentId == "1")
{
setContentView(R.layout.tent1);
}
if(tentId == "2")
{
setContentView(R.layout.tent2);
}
if(tentId == "3")
{
setContentView(R.layout.tent3);
}
}
}
use equals(), not ==
if(tentId.equals("1"))
change onClick method with:
#Override
public void onClick(View v)
{
Intent intent = new Intent(this, TentPage.class);
switch (v.getId()) {
case R.id.button1:
intent.putExtra("tentId", "1");
startActivity(intent);
break;
case R.id.button2:
intent.putExtra("tentId", "2");
startActivity(intent);
break;
case R.id.button3:
intent.putExtra("tentId", "3");
startActivity(intent);
break;
default:
break;
}
and use tentId.equals(""); for String check you must use equals() method and for number value use == like:
if(tentId.equals("1"))
{
setContentView(R.layout.tent1);
}
if(tentId.equals("2"))
{
setContentView(R.layout.tent2);
}
if(tentId.equals("3"))
{
setContentView(R.layout.tent3);
}
Java is a b*%$#ch... Use equals():
if(tentId.equals("1")) ...
Also, according to this answer, Android supports Java 1.7's strings in switch statements, meaning you can rewrite your code in a tidier fashion:
switch(tendId) {
case "1": ...
case "2": ...
case "3": ...
}
Keep in mind that the simplest solution would be to pass tendId as an int and not a string:
intent.putExtra("tendId", 1);
int tendId = intent.getIntExtra("tendId");
Replace your TentPage like:
package com.novator.inweld;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class TentPage extends Activity
{
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Intent intent= getIntent();
String tentId = intent.getStringExtra("tentId");
if(tentId.equals("1"))
{
setContentView(R.layout.tent1);
}
if(tentId.equals("2"))
{
setContentView(R.layout.tent2);
}
if(tentId.equals("3"))
{
setContentView(R.layout.tent3);
}
}
}
Related
I am working on a project in which I used Bottom Navigation Bar. On Nav Bar, I used 4 menu items(Profile, Home, Reservation, Logout), for them I used fragment.
Moving to Home, a list of restaurant will be appear. When the user tap on any restaurant from the list, an activity( name ReservationInfo ) will be opened. There are 3 edit text fields and a button in ReservationInfo activity. When the user click on the button it will move to the fragment(Reservation) which is placed on third position of bottom nav bar.
The question is how to move from activity to fragmentand the fragment is set to the 3rd menu item of the bottom navigation bar.
Here is the code:
Resrvation.java
package restaurantlocator.application;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Toast;
public class Resrvation extends AppCompatActivity {
Button reserve;
ImageButton imageButton;
EditText food, chooseTime, date;
DataBaseHelper db;
// ReservationInfo reservationInfo;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_resrvation);
db = new DataBaseHelper(this);
food = (EditText) findViewById(R.id.etfood);
chooseTime = (EditText) findViewById(R.id.ettime);
date = (EditText) findViewById(R.id.edate);
reserve = (Button) findViewById(R.id.btnreserve);
imageButton = (ImageButton) findViewById(R.id.imgButton);
imageButton.setOnClickListener(new View.OnClickListener()
{
#Override
public void onClick(View v)
{
finish();
}
});
//reservationInfo = new ReservationInfo();
reserve.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
if (!emptyValidation()) {
db.AddData(new Data(food.getText().toString(),
chooseTime.getText().toString(),
date.getText().toString()));
AlertMessage();
food.setText(null);
chooseTime.setText(null);
date.setText(null);
} else {
Toast.makeText(Resrvation.this, "Empty Fields", Toast.LENGTH_SHORT).show();
}
}
private void AlertMessage() {
AlertDialog.Builder builder = new AlertDialog.Builder(Resrvation.this);
builder.setTitle("Reserved!");
builder.setMessage("A notification will be send on your device regarding your reservation.");
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
//move to fragment ReservationInfo
}
});
builder.show();
}
});
}
private boolean emptyValidation() {
if (TextUtils.isEmpty(food.getText().toString()) || TextUtils.isEmpty(chooseTime.getText().toString())) {
return true;
} else {
return false;
}
}
}
BottomNavigation.java
package restaurantlocator.application;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.FrameLayout;
public class BottomNavigation extends AppCompatActivity {
private BottomNavigationView mMianNav;
private FrameLayout mMainFrame;
private HomeActivity homeActivity;
private ReservationInfo reservationInfo;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bottom_navigation);
startService(new Intent(this, NotificationService.class));
mMainFrame = (FrameLayout) findViewById(R.id.main_frame);
mMianNav = (BottomNavigationView) findViewById(R.id.main_nav);
homeActivity = new HomeActivity();
reservationInfo = new ReservationInfo();
setFragment(homeActivity);
//Listener for handling selection events on bottom navigation items
mMianNav.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
#Override
public boolean onNavigationItemSelected(#NonNull MenuItem menuItem) {
switch (menuItem.getItemId()) {
case R.id.tohome:
setFragment(homeActivity);
return true;
case R.id.toresrvation:
setFragment(reservationInfo);
return true;
case R.id.tologout:
logout();
return true;
default:
return false;
}
}
private void logout() {
Intent intent = new Intent(BottomNavigation.this, Registration.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
finish();
}
});
}
private void setFragment(Fragment fragment) {
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.main_frame, fragment);
fragmentTransaction.commit();
fragmentTransaction.addToBackStack(null);
}
public void onBackPressed() {
Intent homeIntent = new Intent(Intent.ACTION_MAIN);
homeIntent.addCategory(Intent.CATEGORY_HOME);
homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(homeIntent);
finish();
}
}
Solution:
Follow the steps below:
Step1: Add the lines as shown in below reserve click listener
reserve.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
....
....
Intent intent = new Intent(Resrvation.this, BottomNavigation.class);
intent.putExtra("FromReservation", "1");
startActivity(intent);
....
}
}
Next, Step2: In your write the below code in onCreate() of BottomNavigation class:
Intent i = getIntent();
String data = i.getStringExtra("FromReservation");
if (data != null && data.contentEquals("1")) {
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.main_frame, new ReservationInfo());
fragmentTransaction.commitNow();
mMianNav.setSelectedItemId(R.id.toresrvation);
}
Try it, If any problem, do comment below.
All you need to do is just use startActivityForResults instead of startActivity when user selects a restaurant from your home fragment.
e.g :
startActivityForResult(yourIntent, 1000);
And on the reservationInfo Activity in the onClick function use
Intent returnIntent = new Intent();
setResult(Activity.RESULT_CANCELED, returnIntent);
finish();
And then in your first activity override onActivityResult() method and set the selected fragment as reservation if request code matches
e.g:
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1000) {
mMianNav.setSelectedItemId(R.id.toresrvation);
}
}
I want, that when you click to open a new screen (Activity), but have a problem, the new screen does not open. What changes are made to the code, so that the new window opened?
package com.android.yalt;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity implements OnClickListener {
Button btnny;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btnny = (Button) findViewById(R.id.ny);
btnny.setOnClickListener(this);
}
#Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.ny:
startActivity(NY.class);
break;
default:
break;
}
}
private void startActivity(Class<NY> class2) {
// TODO Auto-generated method stub
}
}
You have to use
startActivity(new Intent(getBaseContext(), NY.class));
or
Intent i = new Intent(getBaseContext(), NY.class);
startActivity(i);
or In a method format:
public void startMyActivity(Class activityToStart){
startActivity(new Intent(getBaseContext(), activityToStart.class));
}
Just as a sidenote, one can replace getBaseContext() with your own context if one wants to e.g. startActivity(new Intent(yourOnGoingActivityGoesHere.this, yourClassGoesHere.class));
Also as a utility:
/*This is not tested but should work */
public class AndroidUtility(){
/**
*Usage: AndroidUtility.startMyActivity(MainActivity.this, NY.class);
*/
public static void startMyActivity(Activity onGoingActivity, Class activityToStart){
onGoingActivity.startActivity(new Intent(onGoingActivity.getBaseContext(), activityToStart.class));
}
}
In your case the easiest would be:
#Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.ny:
startActivity(new Intent(getBaseContext(), NY.class));
break;
default:
break;
}
}
I Have an activty in my app which uses putextra(int) method to pass the value 0 first when the aactivty is started. Then on pressing a next button it passes 6,Subsequently 12 and so on. But the trouble is on pressing the next second time I found that the value of index received using getextras method is 0.Is it cause i am calling the activity from itself . This is the code snippet:
package com.movie;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.Toast;
public class movielist extends Activity implements OnClickListener{
Button bm[] = new Button[6];
Button nxt,prev;
String namesdb[]=new String[50];
databaseconnect db;
String lang;
int start,index,end;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.mallu_list);
db = new databaseconnect(this);
db.open();
start=this.getIntent().getExtras().getInt("index");
lang =this.getIntent().getExtras().getString("lang");
Toast.makeText(this, start+"", Toast.LENGTH_SHORT).show();
Log.i("info",start+"");
if(!db.isdata(lang))
{
Toast.makeText(this, "No data in Database", Toast.LENGTH_SHORT).show();
finish();
return;
}
end=start+6;
bm[0] = (Button) findViewById(R.id.bm1);
bm[1] = (Button) findViewById(R.id.bm2);
bm[2] = (Button) findViewById(R.id.bm3);
bm[3] = (Button) findViewById(R.id.bm4);
bm[4] = (Button) findViewById(R.id.bm5);
bm[5] = (Button) findViewById(R.id.bm6);
nxt = (Button) findViewById(R.id.nxt);
prev = (Button) findViewById(R.id.prev);
if(start==0)
{
// prev.setBackgroundResource(0);
// prev.setText("");
}
else
prev.setOnClickListener(this);
namesdb = db.getmovie("",lang);
for (int i = 0; start+i < namesdb.length && i<6; i++) {
bm[i].setText(namesdb[start+i]);
bm[i].setOnClickListener(this);
}
int flag=0;
int i=namesdb.length;
Log.i("info",i+"");
Toast.makeText(this, i+"", Toast.LENGTH_SHORT).show();
for(int j=5;j>=i-start;j--)
{
bm[j].setBackgroundResource(0);
flag=1;
}
if(flag==1)
{
// nxt.setBackgroundResource(0);
// nxt.setText("");
}
else
nxt.setOnClickListener(this);
}
#Override
public void onBackPressed() {
// TODO Auto-generated method stub
super.onBackPressed();
Intent myint2 = new Intent(this, list.class);
startActivity(myint2);
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.bm1:
call(namesdb[start],start,lang);
break;
case R.id.bm2:
call(namesdb[start+1],start,lang);
break;
case R.id.bm3:
call(namesdb[start+2],start,lang);
break;
case R.id.bm4:
call(namesdb[start+3],start,lang);
break;
case R.id.bm5:
call(namesdb[start+4],start,lang);
break;
case R.id.bm6:
call(namesdb[start+5],start,lang);
break;
case R.id.nxt:
int i=namesdb.length;
Intent myint2 = new Intent(this,movielist.class);
myint2.putExtra("index",end);
myint2.putExtra("lang",lang);
startActivity(myint2);
case R.id.prev:
if(start==0)
{
prev.setBackgroundResource(0);
}
else
{
myint2 = new Intent(this,movielist.class);
myint2.putExtra("index",start-6);
myint2.putExtra("lang",lang);
startActivity(myint2);}
break;
}
}
public void call(String name,int start2,String lang) {
Intent myint = new Intent(this, detail.class);
myint.putExtra("nameid", name);
myint.putExtra("index", start2);
myint.putExtra("lang", lang);
startActivity(myint);
}
}
Here's your problem. This part of the switch statement:
case R.id.nxt:
int i=namesdb.length;
Intent myint2 = new Intent(this,movielist.class);
myint2.putExtra("index",end);
myint2.putExtra("lang",lang);
startActivity(myint2);
is missing a break at the end. So it falls through to the next case, which starts the activity with different extras.
When switching intents I lose data from the previous onActivityResult I need it to keep both numbers it gets from the user, currently it will keep one number, then when the next is entered it loses the previous, here's code:
package com.eric.theworks;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends Activity implements OnClickListener {
Button width, height, calc;
TextView area;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
width = (Button) findViewById(R.id.button1);
height = (Button) findViewById(R.id.button2);
calc = (Button) findViewById(R.id.button3);
area = (TextView) findViewById(R.id.textView1);
width.setOnClickListener(this);
height.setOnClickListener(this);
calc.setOnClickListener(this);
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(this, Numbers.class);
switch (v.getId()) {
case R.id.button1:
// width
i.putExtra("numbers", "width");
startActivityForResult(i, 1);
break;
case R.id.button2:
// height
i.putExtra("numbers", "height");
startActivityForResult(i, 1);
break;
case R.id.button3:
// calc
break;
}
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (data.getExtras().containsKey("widthInfo")){
width.setText(data.getStringExtra("widthInfo"));
}
if (data.getExtras().containsKey("heightInfo")){
height.setText(data.getStringExtra("heightInfo"));
}
}
}
package com.eric.theworks;
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;
public class Numbers extends Activity implements OnClickListener {
EditText number;
Button sendInfo;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.numbers);
number = (EditText) findViewById(R.id.editText1);
sendInfo = (Button) findViewById(R.id.button1);
sendInfo.setOnClickListener(this);
}
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
String s = number.getText().toString();
Intent i = getIntent();
String msg = i.getStringExtra("numbers");
if (msg.contentEquals("width")) {
i.putExtra("widthInfo", s);
setResult(RESULT_OK, i);
finish();
}
if (msg.contentEquals("height")) {
i.putExtra("heightInfo", s);
setResult(RESULT_OK, i);
finish();
}
}
}
You can use static variable to store the previous data.
Declare static string globally.
static String widthInfo="";
static String heightInfo="";
Also Give different Requestcode.
case R.id.button1:
// width
i.putExtra("numbers", "width");
startActivityForResult(i, 1);
break;
case R.id.button2:
// height
i.putExtra("numbers", "height");
startActivityForResult(i, 2);
Then use it in your onActivityResult.
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case (1): {
if (data.getExtras().containsKey("widthInfo")){
widthInfo=data.getStringExtra("widthInfo")
width.setText(data.getStringExtra("widthInfo"));
} else {
height.setText(heightInfo);
width.setText(widthInfo);
}
}
break;
case (2):
{
if (data.getExtras().containsKey("heightInfo")){
heightInfo=data.getStringExtra("heightInfo")
height.setText(data.getStringExtra("heightInfo"));
}else {
height.setText(heightInfo);
width.setText(widthInfo);
}
}
break;
}
}
you can use Bundle to pass data from one activity to another rather than the intent directly. for example:
Bundle b = new Bundle();
b.putString("SingleClick",a );
b.putString("LongClick", "no");
i.putExtras(b);
and to get the data in another activity use
Bundle bundle = getIntent().getExtras();
String admin = bundle.getString("LongClick");
String s = number.getText().toString();
Intent i = getIntent();
String msg = i.getStringExtra("numbers");
if (msg.contentEquals("width")) {
i.putExtra("widthInfo", s);
setResult(RESULT_OK, i);
finish();
}
make sure the string s has any values....
package nidhin.survey;
import android.app.Activity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.RadioGroup;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;
public class SurveyActivity extends Activity implements OnCheckedChangeListener
{
CheckBox cb;
String myChoice;
RadioButton radio1;
RadioButton radio2;
RadioButton radio3;
RadioButton radio4;
RadioGroup rg;
EditText text1;
Button button1;
Button button2;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
cb=(CheckBox)findViewById(R.id.check);
cb.setOnCheckedChangeListener(this);
RadioGroup rg=(RadioGroup)findViewById(R.id.rg);
radio1=(RadioButton)findViewById(R.id.radio1);
radio2=(RadioButton)findViewById(R.id.radio2);
radio3=(RadioButton)findViewById(R.id.radio3);
radio4=(RadioButton)findViewById(R.id.radio4);
// rg.setOnCheckedChangeListener(this);
rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch(checkedId)
{
case R.id.radio1:
myChoice = "one";
text1.setText(myChoice);
break;
case R.id.radio2:
myChoice = "two";
text1.setText(myChoice);
break;
case R.id.radio3:
myChoice = "three";
text1.setText(myChoice);
break;
case R.id.radio4:
myChoice = "four";
text1.setText(myChoice);
break;
}
}
});
text1=(EditText)findViewById(R.id.etext1);
text1.setText(myChoice);
button1 = (Button) findViewById(R.id.button01);
button1.setOnClickListener(new clicker());
button2 = (Button) findViewById(R.id.button02);
button2.setOnClickListener(new clicker());
}
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked)
{
if (isChecked)
{
cb.setText("Yes , I have a car!");
}
else
{
cb.setText(" ");
}
if (isChecked) {
TextView tv= new TextView (this);
tv.setText("You have a car , nice!");
}
}
class clicker implements Button.OnClickListener
{
public void onClick(View v)
{
if(v==button1)
{
text1.setText(myChoice);
Toast.makeText(getBaseContext(),
"~~~~Successfully submitted~~~",
Toast.LENGTH_LONG).show();
}
if(v==button2)
{
Intent viewDataIntent = new Intent(this, Survey2.class);
String myData = "You should see this";
viewDataIntent.putExtra("valueOne", myData);
startActivity(viewDataIntent);
}
}
}
}
Hello , this seems to be a simple problem , but I cannot find a solution somehow. I am trying to pass from one activity to the other in my android application . So when the second button is clicked , the program must load the new activity.The error i get is with the line - Intent viewDataIntent = new Intent(this, Survey2.class); it says that the constructor Intent(SurveyActivity.clicker, Class) is undefined. Any ideas?
Intent viewDataIntent = new Intent(this, Survey2.class);
should be
Intent viewDataIntent = new Intent(SurveyActivity.this, Survey2.class);
because SurveyActivity.this is your actual Context.
Intent viewDataIntent = new Intent(getApplicationContext(), Survey2.class);
startActivity(viewDataIntent );
Note you are creating new Intent object into View.OnClickListener class, so this is reference of OnClickListener, whereas
public Intent (Context packageContext, Class cls) need a context object as first parameter, so do instead:
Intent viewDataIntent = new Intent(v.getContext(), Survey2.class);
String myData = "You should see this";
viewDataIntent.putExtra("valueOne", myData);
startActivity(viewDataIntent);
or
Intent viewDataIntent = new Intent(SurveyActivity.this, Survey2.class);
String myData = "You should see this";
viewDataIntent.putExtra("valueOne", myData);
startActivity(viewDataIntent);