Tuesday, 20 November 2012

How to Prevent a class being Insiated in c#

Their are many ways to Doing
1- Make The Class Abstract
2- Use Static Class
3- Make Private Constructor

Difference Between Shallow Copy & Deep Copy

Shallow Copy:  In Shallow copy, the Second object is attached to same memory block. hence any change in either will reflect in Second one. This is faster than deep copy.

Deep Copy:  In Deep copy, Structure and data is copied and both behave as two objects.

Example :  System.Array.CopyTo() and System.Array.Clone()




System.Array.Clone() creates a shallow copy

while System.Array.CopyTo()  creates a deep copy

Monday, 23 April 2012

Find controls in window mobiles

 
Control FindControl(string target )
{
    return FindControl(this, target);
}

static Control FindControl(Control root, string target)
{
    if(root.Name.Equals(target))
        return root;
    for(var i=0;i<root.Controls.Count;++i)
    {
        if (root.Controls[i].Name.Equals(target))
            return root.Controls[i];
    }
    for(var i=0;i<root.Controls.Count;++i)
    {
        Control result;
       for(var k=0;k<root.Controls[i].Controls.Count;++k)
       {
           result = FindControl(root.Controls[i].Controls[k], target);
           if(result!=null)
               return result;
       }
    }
    return null;
}

Wednesday, 28 March 2012

Creating A Webservice in php and Calling its using android

//Writing PHP WebService
<?php
// Pull in the NuSOAP code //download nusoap library Soap Library
require_once("lib/nusoap.php");
//making connection
require_once ('connection.php');
// Create the server instance
$server = new soap_server();
// Initialize WSDL support
$server->configureWSDL('hellowsdl', 'urn:hellowsdl');

//For Return Array of Data
$server->wsdl->addComplexType(
    'farmerdetails',
    'complexType',
    'struct',
    'all',
    '',
    array(
        'farmerid' => array('name' => 'farmerid', 'type' => 'xsd:string'),
        'farmername' => array('name' => 'farmername', 'type' => 'xsd:string'),
                                    'phoneno' => array('name' => 'phoneno', 'type' => 'xsd:string')
           
    )
);


// for returning Array of Array
$server->wsdl->addComplexType(
'Farmerdetailsarray',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(
array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:farmerdetails[]')
),
'tns:farmerdetails'
);

//Register Webservice
$server->register('login',                // method name
    array('userid'=>'xsd:string', 'password'=>'xsd:string'),        // input parameters
    array('return' => 'tns:Farmerdetailsarray'),    // output parameters
    'urn:hellowsdl',                    // namespace
    'urn:hellowsdl#login',                // soapaction
    'rpc',                                // style
    'encoded',                            // use
    'Says get farmer preference'            // documentation
);
//Main login function
  function login($userid)
    {
      connection::connect();
        $LoginQuery="select organizationElement_verticalID from tbluserdetail where userid='".$userid."'";
        $LoginExecuteQuery=  mysql_query($LoginQuery) or die("Error in Query");
      
        while($data=mysql_fetch_array($LoginExecuteQuery, MYSQL_ASSOC))
        {
           
           $getfarmer="select farmerid, farmername from tblfarmer where organizationelementid='".$data[organizationElement_verticalID]."'";
            $getfarmerExecuteQuery=  mysql_query($getfarmer) or die("Error in query");
            $count=0;
             $farmer=array();
             while($farmerdetails=mysql_fetch_array($getfarmerExecuteQuery, MYSQL_ASSOC))
             {
                // $farmer[$count]=array("farmerid"=>$farmerdetails[farmerid],"farmername"=>$farmerdetails[farmername]);
                
                 $getfarmerphone="select farmerphone from tblfarmerphone where farmerid='".$farmerdetails[farmerid]."'";
                 $getfarmerphone_execute=mysql_query($getfarmerphone) or die("Error in phone get query");
                 while($farmerphone=  mysql_fetch_array($getfarmerphone_execute, MYSQL_ASSOC))
                 {
                      $farmer[$count]=array("farmerid"=>$farmerdetails[farmerid],"farmername"=>$farmerdetails[farmername],"phoneno"=>$farmerphone["farmerphone"]);
                  //$farmer[$count]=array("phone no"=>$farmerphone["farmerphone"]) ;  
                 }
                
               
              
                 $count++;
             }
            
         return $farmer;
            

         
            }
   
       
       
       
       
       
       
       
    }
   
 

// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);

?>




//Android Calling

import java.util.ArrayList;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import mla.FieldCoordinator.R.string;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.net.ParseException;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class Community extends Activity {
   
    //For message Printing
            private void showmessage(String msg)
            {
                Toast.makeText(getBaseContext(), msg, Toast.LENGTH_LONG).show();       
            }
    private String SOAP_ACTION = "urn:hellowsdl#getoptions";
     private String METHOD_NAME = "login";
     private  String NAMESPACE = "urn:hellowsdl";
     private String URL ="http://localhost/phphack/hellowsdl.php?wsdl";
   
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        try
        {
            Bundle bundle=getIntent().getExtras();
            String userid=bundle.getString("userid");
           
        super.onCreate(savedInstanceState);
        setContentView(R.layout.community);
        ArrayList<String> hi=new ArrayList<String>();
        String a;
        //hi.add("a");
        for(int i=65; i<=90;i++)
        {
            char c=(char)i;
            String c1=Character.toString(c);           
                hi.add(c1);
       
        }
       
        MyAdapter adapter=new MyAdapter(getApplicationContext(), hi,"alp");
        GridView gv=(GridView)findViewById(R.id.gridView1);
        gv.setAdapter(adapter);
       
       
        //GridView Cell Click Event
        gv.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                    long arg3) {
                TextView txt=(TextView)arg1;
                String val=txt.getText().toString();
                GridView gv=(GridView)findViewById(R.id.gridView2);
            ListAdapter la=    gv.getAdapter();
           
           
           
           
            ListView lv=new ListView(getBaseContext());
            lv.setAdapter(la);
            lv.setFilterText(val);
            lv.setTextFilterEnabled(true);
        CharSequence cs=lv.getTextFilter();
        String def="fdsf";
       
           
           
           
               
               
            }
           
        });
       
       
       
        // webservice calling
       
        SoapObject request=new SoapObject(NAMESPACE, METHOD_NAME);
       
        HttpTransportSE androidhttptransport=new HttpTransportSE(URL);
       
       
    //    AndroidHttpTransport androidhttptransport=new AndroidHttpTransport(URL);
        request.addProperty("userid", userid);
        //request.addProperty("password", "123456");
    //    request.addProperty("name2", 3);
       
        SoapSerializationEnvelope envelope= new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet=true;
        envelope.setOutputSoapObject(request);
       
       
       
            androidhttptransport.call(SOAP_ACTION, envelope);
           
       
            Object results=(Object)envelope.getResponse();
       
            String name1=results.toString();
            final ArrayList<String> arrayFrm=new ArrayList<String>();
            String[] data=    name1.split(",");
            String[] val;
            for(int i=0; i<data.length; i++)
            {
            String ss=data[i].replace("farmerdetails", "");
            String s=    ss.replace("[", "");
            String l=    s.replace("{", "");
            String ll=    l.replace("}", "");
            String ll1=    ll.replace("]", "");
                 val=ll1.split(";");
                 if(val.length>=2){
                 arrayFrm.add((val[0].replace("farmerid=", "")).trim());
                 arrayFrm.add((val[1].replace("farmername=", "")).trim());
                 arrayFrm.add((val[2].replace("phoneno=", "")).trim());}
                           
            }
           
            MyAdapter alldata=new MyAdapter(getApplicationContext(), arrayFrm,"grd");
            GridView alldaagrid=(GridView)findViewById(R.id.gridView2);
            alldaagrid.setAdapter(alldata);
           
            //gridview cell click
            alldaagrid.setOnItemClickListener(new OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> arg0, View arg1,
                        int arg2, long arg3) {
                    Intent communitydashboard=new Intent(getBaseContext(), CommunityDashboard.class);   
                    communitydashboard.putExtra("id", arrayFrm.get(arg2-2));
                    communitydashboard.putExtra("name", arrayFrm.get(arg2-1));
                    communitydashboard.putExtra("pnum", arrayFrm.get(arg2));
                    startActivity(communitydashboard);
                   
                   
                }
            });
           
           
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
        //
       
       
       
       
       
       
       
       
       
        }
        catch(Exception e)
        {
            showmessage(e.getMessage().toString());
       
        }
    }
   
   
   
   
   
    //
   
    public class MyAdapter extends BaseAdapter {

        private Context context;
       
        private ArrayList<String> list; 
        private String type;
        public MyAdapter(Context context,ArrayList<String> list, String type) {
            this.context = context;
            this.list=list;
            this.type=type;
        }

        public int getCount() {
            return list.size(); 
        }

        public Object getItem(int position) {
            return list.get(position); 
        }

        public long getItemId(int position) {
            return position;
        }

        public View getView(int position, View convertView, ViewGroup parent) {
            TextView tv;
            if (convertView == null) {
                tv = new TextView(context);
                tv.setGravity(Gravity.CENTER);
               // tv.setLayoutParams(new GridView.LayoutParams(85, 85));
            }
            else {
                tv = (TextView) convertView;
            }
            if(type=="alp"){
            tv.setTextSize(25);}
            else
            {
                tv.setTextSize(18);
            }
            //tv.setTextColor(Color.BLACK);
                tv.setText(list.get(position));
              
            return tv;
        }
    }


}

Tuesday, 6 March 2012

Android Title Animaion

package popupshow.deepak;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewParent;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.view.animation.TranslateAnimation;
import android.widget.TextView;
import android.widget.Toast;

public class PopupshowActivity extends Activity {
   
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
       
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
      //Get The Title
        View title=getWindow().findViewById(android.R.id.title);
            
        ViewParent parent=title.getParent();
         View parentview=(View)parent;
        parentview.setBackgroundColor(Color.rgb(100, 149, 237));
        Animation hyper=AnimationUtils.loadAnimation(this,android.R.anim.fade_out);

 //Creating animation object for transition of title 
        Animation isfromleft= new TranslateAnimation(Animation.RELATIVE_TO_SELF,0.0f,Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f);
        isfromleft.setDuration(10000);
        isfromleft.setInterpolator(new AccelerateInterpolator());
        isfromleft.setAnimationListener(animater);
       
       
          parentview.setAnimation(isfromleft);
   
              
       
       
    }
   
    private Animation.AnimationListener animater=new Animation.AnimationListener() {
       
        @Override
        public void onAnimationStart(Animation animation) {
            // TODO Auto-generated method stub
           
        }
       
        @Override
        public void onAnimationRepeat(Animation animation) {
           
           
        }
       
        @Override
        public void onAnimationEnd(Animation animation) {
            animation.start();
           
           
        }
    };   
   
}

Saturday, 25 February 2012

Parsing JSON in Android and Show in List

//main
package com.pxr.tutorial.json;

import java.util.ArrayList;
import java.util.HashMap;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

import com.pxr.tutorial.xmltest.R;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;

public class Main extends ListActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.listplaceholder);
       
        ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
     
      
        JSONObject json = JSONfunctions.getJSONfromURL("http://api.geonames.org/earthquakesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&username=demo");
               
        try{
           
            JSONArray  earthquakes = json.getJSONArray("earthquakes");
           
            for(int i=0;i<earthquakes.length();i++){                       
                HashMap<String, String> map = new HashMap<String, String>();   
                JSONObject e = earthquakes.getJSONObject(i);
               
                map.put("id",  String.valueOf(i));
                map.put("name", "Earthquake name:" + e.getString("eqid"));
                map.put("magnitude", "Magnitude: " +  e.getString("magnitude"));
                mylist.add(map);           
            }       
        }catch(JSONException e)        {
             Log.e("log_tag", "Error parsing data "+e.toString());
        }
       
        ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.main,
                        new String[] { "name", "magnitude" },
                        new int[] { R.id.item_title, R.id.item_subtitle });
       
        setListAdapter(adapter);
       
        final ListView lv = getListView();
        lv.setTextFilterEnabled(true);   
        lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {               
                @SuppressWarnings("unchecked")
                HashMap<String, String> o = (HashMap<String, String>) lv.getItemAtPosition(position);                   
                Toast.makeText(Main.this, "ID '" + o.get("id") + "' was clicked.", Toast.LENGTH_SHORT).show();

            }
        });
    }
}


//json function
package com.pxr.tutorial.json;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
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.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

public class JSONfunctions {

    public static JSONObject getJSONfromURL(String url){
        InputStream is = null;
        String result = "";
        JSONObject jArray = null;
       
        //http post
        try{
                HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost(url);
                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());
        }
       
      //convert response to string
        try{
                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");
                }
                is.close();
                result=sb.toString();
        }catch(Exception e){
                Log.e("log_tag", "Error converting result "+e.toString());
        }
       
        try{
           
            jArray = new JSONObject(result);           
        }catch(JSONException e){
                Log.e("log_tag", "Error parsing data "+e.toString());
        }
   
        return jArray;
    }
}

Thursday, 23 February 2012

Image Showing in DataList

Showproduct.aspx
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage2.master" CodeFile="ShowProducts.aspx.cs" EnableEventValidation="false" Inherits="ShowProducts" %>

<script runat="server">

  
</script>

<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
 
        <div>
            <asp:DataList ID="DataList1" runat="server" RepeatColumns="3"
                RepeatDirection="Horizontal" ShowFooter="False" BackColor="White"
                BorderColor="Black" BorderStyle="Double" BorderWidth="5px" CellPadding="10"
                CellSpacing="20" Font-Bold="False" Font-Italic="False" Font-Overline="False"
                Font-Strikeout="False" Font-Underline="False" ForeColor="Black"
                GridLines="Both" HorizontalAlign="Center">
                <FooterStyle BackColor="White" ForeColor="#333333" />
                <ItemStyle BackColor="White" ForeColor="#333333" />
                <SeparatorStyle BackColor="#3333FF" Font-Bold="False" Font-Italic="False"
                    Font-Overline="False" Font-Strikeout="False" Font-Underline="False"
                    ForeColor="#CC00FF" HorizontalAlign="Center" VerticalAlign="Middle" />
                <SelectedItemStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
                <ItemTemplate>
                <table><tr>
                   
                <td><%#DataBinder.Eval(Container.DataItem,"images") %></td>
                <td>&nbsp;&nbsp;&nbsp</td>
                <td><h3><%#DataBinder.Eval(Container.DataItem,"productname") %></h3><br>
                <b>MRP</b> <%#DataBinder.Eval(Container.DataItem, "productmrp") %><br>
                <b>Our Price</b> <%#DataBinder.Eval(Container.DataItem, "plashprice") %><br>
                <b>Discount</b> <%#DataBinder.Eval(Container.DataItem, "Discount")%>%
                <br />
                <asp:Button ID="Button2" runat="server" Text="Get Details" CommandArgument='<%#Eval("productid") %>'
                        onclick="Button2_Click" />
                </td>
               
                </tr></table>
                 
                </ItemTemplate>
           
            </asp:DataList>
         
   
            <asp:Button ID="Button1" runat="server" Text="Button" />
   
    </div>
    </asp:Content>


//handler.ashx

<%@ WebHandler Language="C#" Class="Handler" %>

using System;
using System.Web;
using System.Data.Odbc;

public class Handler : IHttpHandler {
   
    public void ProcessRequest (HttpContext context) {

        OdbcConnection con = new OdbcConnection(connection.connection1);
        con.Open();
        string imagegetquery = "select imagepath from tblproductimagemap where productid='" + context.Request.QueryString["productid"] + "'";
        OdbcCommand imagegetcommand = new OdbcCommand(imagegetquery, con);
        OdbcDataReader imagereader = imagegetcommand.ExecuteReader();
        imagereader.Read();
        context.Response.BinaryWrite((byte[])imagereader["imagepath"]);
        imagereader.Close();
        con.Close();
      
        //context.Response.ContentType = "text/plain";
        //context.Response.Write("Hello World");
    }

    public bool IsReusable {
        get {
            return false;
        }
    }

}


//showproduct.aspx.cs

  private void binddatalist()
    {
        DataTable dt= new DataTable();
        OdbcConnection con = new OdbcConnection(connection.connection1);
        con.Open();
        string imagegetquery = "select productid, productname, productbrand, productmrp, plashprice, discount from tblproductmaster";
        OdbcCommand imagegetcommand = new OdbcCommand(imagegetquery, con);
        OdbcDataAdapter imageadpter = new OdbcDataAdapter(imagegetcommand);
        imageadpter.Fill(dt);

        DataColumn imagecolumn = new DataColumn("images", typeof(string));
        dt.Columns.Add(imagecolumn);
        if (dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i][imagecolumn]=string.Format("<img src='Handler.ashx?productid={0}' alt='View Details' style='width:100px; height:100px'/>", dt.Rows[i][0].ToString());

            }
        }
       
       
        DataList1.DataSource = dt;
        DataList1.DataBind();

       

    }
   

Monday, 20 February 2012

Calling WebService in Android and Parse its XML

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());

         
       
    }

}

Email Sending Codes for C#

using System;
using System.Net;
using System.Net.Mail;
using System.Collections;
public class MailSender
{
    public static bool SendEmail(
        string pGmailEmail,
        string pGmailPassword,
        string pTo,
        string pSubject,
        string pBody,

        ArrayList pAttachmentPath)
    {
        try
        {
            NetworkCredential loginInfo = new NetworkCredential(pGmailEmail, pGmailPassword);
            MailMessage msg = new MailMessage();
            msg.From = new MailAddress(pGmailEmail);
            msg.To.Add(new MailAddress(pTo));
            //msg.Bcc.Add(new MailAddress("ashok.prasad@akshamaala.com"));
            msg.Subject = pSubject;
            msg.Body = pBody;
            msg.IsBodyHtml = true;
            System.Net.Mail.Attachment attachment;
            for (int i = 0; i < pAttachmentPath.Count; i++)
            {
                attachment = new System.Net.Mail.Attachment(Convert.ToString(pAttachmentPath[i]));
                msg.Attachments.Add(attachment);
            }
            SmtpClient client = new SmtpClient("smtp.gmail.com");
            client.EnableSsl = true;
            client.UseDefaultCredentials = false;
            client.Credentials = loginInfo;
            client.Send(msg);
            msg.Dispose();
            return true;
        }
        catch (Exception ex)
        {
            return false;
        }
    }