package Act.dscl;
import java.io.IOException;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class displayall extends Activity {
String result;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Bundle bundle= getIntent().getExtras();
String result1=null;
final String dateid=bundle.getString("datenew");
final String userid=bundle.getString("userid");
setContentView(R.layout.displaylayout);
Button backbutton=(Button)findViewById(R.id.back);
backbutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent jl= new Intent(getBaseContext(),myactivity.class);
jl.putExtra("userid", userid);
startActivity(jl);
}
});
HttpClient httpclient1=new DefaultHttpClient();
HttpPost httppost1= new HttpPost("http://14.102.87.2/dsclwebservice/service.asmx/displayactivitywithdate");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("userid",userid));
nameValuePairs.add(new BasicNameValuePair("datein",dateid));
try {
httppost1.setEntity(new UrlEncodedFormEntity(nameValuePairs));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ResponseHandler<String> responseHandler = new BasicResponseHandler();
try {
result1= httpclient1.execute(httppost1, responseHandler);
}
catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//parse result message
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = null;
try {
db = dbf.newDocumentBuilder();
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
InputSource is =new InputSource();
is.setCharacterStream(new StringReader(result1));
Document doc = null;
try {
doc = db.parse(is);
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//Get the xml string from the server
NodeList nodes = doc.getElementsByTagName("string");
//fill in the list items from the XML document
String Message = null;
try
{
Node es1= nodes.item(0);
NodeList fstNm1=((Node)es1).getChildNodes();
Message=(fstNm1.item(0)).getNodeValue();
}
catch(Exception ex)
{
String message= ex.getMessage();
}
String[] temp= new String[5];
temp=Message.split("\\.");
TextView txtview=(TextView)findViewById(R.id.textView1);
String abcd=temp[0].toString();
txtview.setText(abcd.toUpperCase());
String alltext=temp[1];
String[] alltextarray=alltext.split("2");
String alltextsecond=alltextarray[1];
String[] alltextsecondarray=alltextsecond.split("3");
TextView firstactivity=(TextView)findViewById(R.id.textView2);
firstactivity.setText("Activity 1"+alltextsecondarray[1].toString());
TextView secondActivity=(TextView)findViewById(R.id.textView3);
secondActivity.setText("Activity 2 "+alltextsecondarray[0].toString());
TextView thirdActivity=(TextView)findViewById(R.id.textView4);
thirdActivity.setText("Activity 3"+alltextarray[0].toString());
}
}
import java.io.IOException;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class displayall extends Activity {
String result;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Bundle bundle= getIntent().getExtras();
String result1=null;
final String dateid=bundle.getString("datenew");
final String userid=bundle.getString("userid");
setContentView(R.layout.displaylayout);
Button backbutton=(Button)findViewById(R.id.back);
backbutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent jl= new Intent(getBaseContext(),myactivity.class);
jl.putExtra("userid", userid);
startActivity(jl);
}
});
HttpClient httpclient1=new DefaultHttpClient();
HttpPost httppost1= new HttpPost("http://14.102.87.2/dsclwebservice/service.asmx/displayactivitywithdate");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("userid",userid));
nameValuePairs.add(new BasicNameValuePair("datein",dateid));
try {
httppost1.setEntity(new UrlEncodedFormEntity(nameValuePairs));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ResponseHandler<String> responseHandler = new BasicResponseHandler();
try {
result1= httpclient1.execute(httppost1, responseHandler);
}
catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//parse result message
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = null;
try {
db = dbf.newDocumentBuilder();
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
InputSource is =new InputSource();
is.setCharacterStream(new StringReader(result1));
Document doc = null;
try {
doc = db.parse(is);
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//Get the xml string from the server
NodeList nodes = doc.getElementsByTagName("string");
//fill in the list items from the XML document
String Message = null;
try
{
Node es1= nodes.item(0);
NodeList fstNm1=((Node)es1).getChildNodes();
Message=(fstNm1.item(0)).getNodeValue();
}
catch(Exception ex)
{
String message= ex.getMessage();
}
String[] temp= new String[5];
temp=Message.split("\\.");
TextView txtview=(TextView)findViewById(R.id.textView1);
String abcd=temp[0].toString();
txtview.setText(abcd.toUpperCase());
String alltext=temp[1];
String[] alltextarray=alltext.split("2");
String alltextsecond=alltextarray[1];
String[] alltextsecondarray=alltextsecond.split("3");
TextView firstactivity=(TextView)findViewById(R.id.textView2);
firstactivity.setText("Activity 1"+alltextsecondarray[1].toString());
TextView secondActivity=(TextView)findViewById(R.id.textView3);
secondActivity.setText("Activity 2 "+alltextsecondarray[0].toString());
TextView thirdActivity=(TextView)findViewById(R.id.textView4);
thirdActivity.setText("Activity 3"+alltextarray[0].toString());
}
}
No comments:
Post a Comment