Android Development & Microsoft Visual Studios .NET??

Put your problem here if it does not fit any of the other categories.

Android Development & Microsoft Visual Studios .NET??

Postby -vB » Tue Feb 22, 2011 12:57 am

Is this possible, If so, Can someone guide me the right way on how to set this up??
I used, Found a few things of people talking about doing it, But nothing
that shows me how to do it, Thanks in advanced. =]
Once Poster
Once Poster
Posts: 1
Joined: Mon Feb 21, 2011 11:39 pm


Re: Android Development & Microsoft Visual Studios .NET??

Postby strider2023 » Mon Feb 28, 2011 11:25 am

.net code snippet....

Code: Select all
protected void Page_Load(object sender, EventArgs e)
        JavaScriptSerializer js = new JavaScriptSerializer();
        int i=0;
        string []str = new string[3];
        while (i < 3)
            Person p1 = new Person();
            p1.firstName = "jai";
            p1.lastName = "dev";
            p1.department = "development";

            str[i] = js.Serialize(p1);

            if (i + 1 < 3)


    public class Person
        public string firstName, lastName, department;

and the android code...

Code: Select all
public class Main extends Activity implements DisplayToast{
   JSONArray jArray;
   JSONObject json_data;
   InputStream is = null;
   String result = "";
   private String[] lastName , firstName, department;
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        for (int i = 0; i < firstName.length; i++) {
              Toast.makeText(getBaseContext(), "First Name: " +  firstName[i] +" Last Name: " + lastName[i] + " Department: " + department[i], Toast.LENGTH_SHORT).show();
    * This functions gets the details of the facility info from the server and synchronizes it with the local database.
    * @param str
    public void getChecklist(String str) {
        ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        nameValuePairs.add(new BasicNameValuePair("fname","test1"));
        //http post
                HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost(str);
                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                HttpResponse response = httpclient.execute(httppost);
                HttpEntity entity = response.getEntity();
                is = entity.getContent();
        }catch(Exception e){
                Log.e("log_tag", "Error in http connection "+e.toString());
                Toast.makeText(getBaseContext(), "Error in http connection. Please try again or check if internet connection is available.", Toast.LENGTH_SHORT).show();
        //convert response to string
            BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
                StringBuilder sb = new StringBuilder();
                String line = null;
                while ((line = reader.readLine()) != null) {
                        sb.append(line + "\n");
                Toast.makeText(getBaseContext(), result, Toast.LENGTH_SHORT).show();
        }catch(Exception e){
                Log.e("log_tag", "Error converting result "+e.toString());
                Toast.makeText(getBaseContext(), "Error parsing data. Please contact system adminstrator. 1", Toast.LENGTH_SHORT).show();
        //parse json data
                jArray = new JSONArray(result);
                //firstName = new String[jArray.length()];
                //lastName = new String[jArray.length()];
                //department = new String[jArray.length()];
                for(int i=0;i<jArray.length();i++){
                        json_data = jArray.getJSONObject(i);
                        //firstName[i] = json_data.getString("firstName");
                        //lastName[i] = json_data.getString("lastName");
                        //department[i] = json_data.getString("department");
        }catch(JSONException e){
                Log.e("log_tag", "Error parsing data "+e.toString());
                Toast.makeText(getBaseContext(), "Error parsing data. Please contact system adminstrator. 2", Toast.LENGTH_SHORT).show();

   public void displayToast(String string) {
      // TODO Auto-generated method stub
      Toast.makeText(getBaseContext(), string, Toast.LENGTH_SHORT).show();
Senior Developer
Senior Developer
Posts: 126
Joined: Tue Mar 02, 2010 6:34 am
Location: Chennai, India


Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 4 guests