i want to show string one activity to another activity another activity is the sudoku game class and want to show the string like a sudoku puzzle on the sudoku screen board on the sudoku game class.sudoku grid is 9*9.
Asked
Active
Viewed 174 times
3 Answers
1
You could have easily found this out by searching google, or the many existing questions on this site such as this. But here is what you need to do...
You need to pass it as an extra:
String puzzle = "630208010200050089109060030"+
"008006050000187000060500900"+
"09007010681002000502003097";
Intent i = new Intent(this, ToClass.class);
i.putExtra("epuzzle", puzzle);
startActivity(i);
Then extract it from your new activity like this:
Intent intent = getIntent();
String easyPuzzle = intent.getExtras().getString("epuzzle");
0
I am not sure I understood the question the rigth way but if you want to send a string from one activity to the other you should use intent put extras see here: http://developer.android.com/reference/android/content/Intent.html#putExtra%28java.lang.String,%20android.os.Bundle%29
vallllll
- 2,691
- 6
- 41
- 75
-
thanks for help. please give me proper code for this .it's urgent. – Sandeeep Jul 16 '11 at 12:38
0
In the parent Activity I would create an Intent to the Child activity. Then use putExtra to send data. Then use getExtra or any variation on that to get the String. I have used getStringExtra in this example.
Intent childActivity = new Intent(this, Child.class);
childActivity.putExtra("parent_parameter", "This String is for child");
startActivity(childActivity);
In the Child.java Activity.
Intent childIntent = getIntent();
String fromParent = childIntent.data.getStringExtra("parent_parameter");
kensen john
- 5,213
- 4
- 27
- 36
-
whats the point in repeating an answer thats already been given twice? I only added mine to show him some example code! – Kenny Jul 16 '11 at 13:01