my activity flow , Login page->mainpage(in this i have a button to go to Userprofile which has a onclick method)-> button onclick method is "startactivity(Userprofile)"
I have a onClick
method which loads the activity Userprofile
.
I want to load the details of the user, i have some static
variables but no luck.
public class Userprofile extends AppCompatActivity {
TextView textView , textView1 , textView2 ;
Context context_userprofile;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_userprofile);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
func_userprofile_show();
}
public void func_userprofile_show(){
String type = "linkuser";
DatabaseLink databaseLink = new DatabaseLink(this);
databaseLink.execute(type);
context_userprofile = getApplicationContext();
textView = (TextView)findViewById(R.id.tvprofilepage_user);
assert textView != null;
textView.setText(DatabaseLink.thename);
textView1 = (TextView)findViewById(R.id.tvprofilepage_ign);
assert textView1 != null;
textView1.setText(DatabaseLink.theign);
textView2 = (TextView)findViewById(R.id.tvprofilepage_emailid);
assert textView2 != null;
textView2.setText(DatabaseLink.theemail);
}
}
Now this is a method from diffrent class which extends AsyncTask
and "theign" is showing in AlertDialog
but not in TextView
.
public void decodejson() {
try {
JSONObject jsonObj = new JSONObject(myJSON);
details_json = jsonObj.getJSONArray(TAG_RESULTS);
for (int i = 0; i < details_json.length(); i++) {
JSONObject c = details_json.getJSONObject(i);
thename = c.getString(TAG_NAME);
theign= c.getString(TAG_IGN);
theemail = c.getString(TAG_EMAIL);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
protected void onPreExecute() {
alertDialog = new AlertDialog.Builder(context).create();
alertDialog.setTitle("User Profile Loading...");
}
@Override
protected void onPostExecute(String result) {
myJSON = result;
decodejson();
alertDialog.setMessage(theign);
alertDialog.show();
}