Untitled
unknown
java
2 years ago
2.1 kB
2
Indexable
Never
package com.rafsanahsan.lab3cse489; import androidx.appcompat.app.AppCompatActivity; import android.annotation.SuppressLint; import android.app.Activity; import android.os.AsyncTask; import android.os.Bundle; import android.webkit.WebView; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import java.util.ArrayList; import java.util.List; public class MyAttendanceActivity extends Activity { private WebView webview; private String URL = "http://www.muthosoft.com/univ/attendance/report.php"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my_attendance); webview = findViewById(R.id.webview); String[] keys = {"CSE489-Lab","year","semester","course","section","sid"}; String[] values = {"true","2022","1","CSE489","1","2019360003"}; httpRequest(keys,values); } @SuppressLint("StaticFieldLeak") private void httpRequest(final String key[], final String values[]){ new AsyncTask<Void, Void, String>(){ @Override protected String doInBackground(Void... param){ try { List<NameValuePair>params = new ArrayList<NameValuePair>(); for (int i =0; i<key.length; i++){ params.add(new BasicNameValuePair(key[i],values[i])); } String data = JSONParser.getInstance().makeHttpRequest(URL, "POST", params); return data; }catch (Exception ex){ ex.printStackTrace(); } return null; } @Override protected void onPostExecute(String data){ if (data != null){ try{ webview.loadData(data, "text/html", "UTF-8"); }catch (Exception e){ e.printStackTrace(); } } } }.execute(); } }