I have a method name Request() in the onCreate method of the activity.
private void Request() { new PostDataAsyncTask(textEmail, tValue).execute(); } Iam passing two strings in it and the async class is as follows:
public class PostDataAsyncTask extends AsyncTask<String, String, String> { GameActivity game= new GameActivity(); private String data,data1; public PostDataAsyncTask(String textEmail, String hello) { data = textEmail; data1= hello; } long date = System.currentTimeMillis(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMM MM dd, yyyy h:mm a"); String dateString = simpleDateFormat.format(Long.valueOf(date)); protected void onPreExecute() { super.onPreExecute(); } @Override protected String doInBackground(String... strings) { try { postText(); } catch (Exception e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(String lenghtOfFile) { } private void postText(){ try{ String postReceiverUrl = "http://techcube.pk/game/game.php"; HttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(postReceiverUrl); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair("email", data)); nameValuePairs.add(new BasicNameValuePair("score", data1)); nameValuePairs.add(new BasicNameValuePair("datetime", dateString)); httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpClient.execute(httpPost); HttpEntity resEntity = response.getEntity(); if (resEntity != null) { String responseStr = EntityUtils.toString(resEntity).trim(); Log.v("SuccesS", "Response: " + responseStr); } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } Now what i want is that i want to get the value of responseStr in my MainActivity that is generated when posttext method called. How to show this responseStr value in the MainActivity? Remember there is a new class that i made named as PostDataAsyncTask so how to access responseStr from this class and show it in my mainActivity as a Toast or Textview? Please Help