-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNext.java
More file actions
128 lines (100 loc) · 2.77 KB
/
Copy pathNext.java
File metadata and controls
128 lines (100 loc) · 2.77 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
120
121
122
123
124
125
126
127
128
package com.example.project;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONArray;
import org.json.JSONObject;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.TextView;
public class Next extends Activity{
String diss="";
String comb="";
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.next);
Intent intent=getIntent();
String s=intent.getStringExtra(MainActivity.STRING1);
String s1=intent.getStringExtra(MainActivity.STRING2);
comb=s.concat(s1);
GetData();
//textV.setText(diss);
}
public void GetData()
{
String result="";
InputStream isr=null;
try
{
HttpClient httpclient=new DefaultHttpClient();
HttpPost httppost= new HttpPost("http://172.168.250.117/getData3.php");
HttpResponse response=httpclient.execute(httppost);
HttpEntity entity=response.getEntity();
isr=entity.getContent();
}
catch(Exception e)
{
Log.e("log_tag","Error in http connection"+e.toString());
}
try
{
BufferedReader reader= new BufferedReader(new InputStreamReader(isr,"iso-8859-1"),8);
StringBuilder sb=new StringBuilder();
String line=null;
while((line=reader.readLine())!=null)
{
sb.append(line+"\n");
}
isr.close();
result=sb.toString();
}
catch(Exception e)
{
Log.e("log_tag","Error converting result "+e.toString());
}
try
{
JSONArray jArray=new JSONArray(result);
final String[] srt=new String[jArray.length()];
for(int i=0;i<jArray.length();i++)
{
JSONObject json=jArray.getJSONObject(i);
srt[i]=(json.getString("src").trim()).concat(json.getString("dest").trim());
}
TextView tex=(TextView)findViewById(R.id.textVie);
TextView tex1=(TextView)findViewById(R.id.textVi);
tex1.setTextColor(Color.rgb(72, 118, 255));
tex1.setTextSize(18);
for(int i=0;i<srt.length;i++)
{
if(srt[i].equals(comb))
{
JSONObject json=jArray.getJSONObject(i);
diss=diss+json.getString("route")+"\n\n";
}
}
tex.setText(diss);
tex.setTextColor(Color.WHITE);
tex.setTextSize(15);
}
catch(Exception e)
{
Log.e("log_tag","error parsing data "+e.toString());
}
}
}