-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainActivity.java
More file actions
119 lines (89 loc) · 3.63 KB
/
MainActivity.java
File metadata and controls
119 lines (89 loc) · 3.63 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package com.example.v_25.my_task;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.sql.Driver;
import java.util.ArrayList;
import java.util.List;
import android.animation.AnimatorSet;
import android.animation.AnimatorInflater;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
public class MainActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.content_main);
Login l = new Login();
l.execute(new String[] { "http://dev192.com/phoenix_dev/webservice/?type=login" });
}
class Login extends AsyncTask<String, Void, String> {
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
System.out.println("Prakash");
// prog.setVisibility(View.VISIBLE);
}
@Override
protected String doInBackground(String... urls) {
// TODO Auto-generated method stub
System.out.println("Prakash_background");
String response = "";
try {
String url = urls[0];
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>();
nameValuePair.add(new BasicNameValuePair("username","yourvalue"));
nameValuePair.add(new BasicNameValuePair("password","yourvalue#"));
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair));
HttpResponse httpresponse = httpClient.execute(httpPost);
InputStream in = httpresponse.getEntity().getContent();
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String s = "";
while ((s = br.readLine()) != null) {
response += s;
System.out.print("EVENTLIST response is" + response);
Log.d("Login Success", "response value" + response);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return response;
}
@Override
protected void onPostExecute(String result) {
//
try {
// JSONObject o=new JSONObject(result);
JSONArray arr = new JSONArray(result);
for (int i = 0; i < arr.length(); i++) {
JSONObject obj = arr.getJSONObject(i);
String rank = obj.getString("rank");
String title = obj.getString("title");
}
} catch (Exception e) {
}
}
}
}