at begining i want to say sorry for my bad english i hope u understand me. I want to copy one string to another activity so i create :
package com.example.kliker;
import android.app.Application;
public class GlobalClass extends Application{
private String name;
private String email;
public String getName() {
return name;
}
public void setName(String aName) {
name = aName;
}
public String getEmail() {
return email;
}
public void setEmail(String aEmail) {
email = aEmail;
}
}
and in activity to set i use:
final GlobalClass globalVariable = (GlobalClass) getApplicationContext();
globalVariable.setEmail("1");
globalVariable.setName("1");
and when i want get:
final GlobalClass globalVariable = (GlobalClass) getApplicationContext();
a = globalVariable.getEmail();
b = globalVariable.getName();
mTextView.setText(a);
But it doesn't work ? I should refresh activity or something like that ?
http://speedy.sh/dvt94/Desktop.rar Manifest,activity from i get and set, activity set, activity get
I would like to make one activity outstay data about category and food also i want to make another activity when we are in it and when we click on food it send informations about itself category and chosen food, main activity download that information and by means of them it build graphic sentence
Use Bundle API - http://developer.android.com/reference/android/os/Bundle.html.
In your A Activity -
Intent intent = new Intent(A.this, B.class);
Bundle bundle = new Bundle();
bundle.putString("value", "String Value");
intent.putExtras(bundle);
startActivity(intent);
And, in B Activity -
Intent i = getIntent();
Bundle extras = i.getExtras();
String value = extras.getString("value");
You would be interested in this http://hmkcode.com/android-passing-data-to-another-activities/
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments