Ich bin ein Anfänger in Android, ich frage mich, wie ich Daten von meinem oncreateView an meine asynchrone Aufgabe übergeben. Zum Beispiel habe ich eine Benutzer-ID in meinem oncreate Wie kann ich diese Benutzer-ID zu meinem asyntask aufrufen?onCreateView-Wert zu AsyncLogin
Hier ist mein Code.
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// myView = inflater.inflate(R.layout.currently_history_rvmainfragment,container, false);
myView = inflater.inflate(R.layout.currently_history_rvmainfragment,container, false);
Bundle bundle = this.getArguments();
int myInt = bundle.getString("key","")
//I HAVE A DATA HERE AND I WANT TO PASS IT TO MY ASYNC TASK
new AsyncLogin().execute();
return myView;
}
private class AsyncLogin extends AsyncTask<String, String, String> {
ProgressDialog pdLoading = new ProgressDialog(getActivity());
HttpURLConnection conn;
URL url = null;
MaincommentShowmore maincommentShowmore= new MaincommentShowmore();
// I WANT TO PASS IT HERED SO THAT I MAY CALL IT TO MY URL
@Override
protected void onPreExecute() {
super.onPreExecute();
//this method will be running on UI thread
pdLoading.setMessage("\tLoading...");
pdLoading.setCancelable(false);
pdLoading.show();
}
@Override //SO THAT I MAY ADD INT VALUES IN THIS URL
protected String doInBackground(String... params) {
try {
// Enter URL address where your json file resides
// Even you can make call to php file which returns json data
url = new URL("http://192.168.1.6/jmiappphp/showRateCommentShowMore.php");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return e.toString();
}
try {
// Setup HttpURLConnection class to send and receive data from php and mysql
conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(READ_TIMEOUT);
conn.setConnectTimeout(CONNECTION_TIMEOUT);
conn.setRequestMethod("GET");
// setDoOutput to true as we recieve data from json file
conn.setDoOutput(true);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
return e1.toString();
}
Danke, dass ich das benutzt habe und es funktioniert hat omg Du hast meinen Schlussstein gerettet HAHAHAHA <3 Mehr Power –