-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBookingBackground.java
More file actions
103 lines (78 loc) · 3.04 KB
/
BookingBackground.java
File metadata and controls
103 lines (78 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package com.example.omsaiwashing;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
public class BookingBackground extends AsyncTask<String,Void,String> {
Context context;
AlertDialog alertDialog;
BookingBackground(Context ctx) {
context = ctx;
}
@Override
protected String doInBackground(String... voids) {
String result = "";
String date = voids[0];
String time = voids[1];
String vechicle = voids[2];
String contact = voids[3];
String type = voids[4];
String login_url = "https://omsai12.000webhostapp.com/bookingForm.php";
try {
URL url = new URL(login_url);
HttpURLConnection http = (HttpURLConnection) url.openConnection();
http.setRequestMethod("POST");
http.setDoInput(true);
http.setDoOutput(true);
OutputStream ops = http.getOutputStream();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(ops,"UTF-8"));
String data = URLEncoder.encode("date","UTF-8")+"="+URLEncoder.encode(date,"UTF-8")
+"&&"+URLEncoder.encode("time","UTF-8")+"="+URLEncoder.encode(time,"UTF-8")+"&&"+URLEncoder.encode("vechicle","UTF-8")+"="+URLEncoder.encode(vechicle,"UTF-8")+"&&"+URLEncoder.encode("contact","UTF-8")+"="+URLEncoder.encode(contact,"UTF-8")+"&&"+URLEncoder.encode("type","UTF-8")+"="+URLEncoder.encode(type,"UTF-8");
writer.write(data);
writer.flush();
writer.close();
ops.close();
InputStream ips = http.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(ips,"ISO-8859-1"));
String line ="";
while ((line = reader.readLine()) != null)
{
result += line;
}
reader.close();
ips.close();
http.disconnect();
return result;
} catch (MalformedURLException e) {
result = e.getMessage();
} catch (IOException e) {
result = e.getMessage();
}
return result;
}
@Override
protected void onPreExecute() {
alertDialog = new AlertDialog.Builder(context).create();
//alertDialog.setTitle("Login Status");
}
@Override
protected void onPostExecute(String result) {
alertDialog.setMessage(result);
alertDialog.show();
}
@Override
protected void onProgressUpdate(Void... values) {
super.onProgressUpdate(values);
}
}