Sunday, December 6, 2015

How to Send Email with android



Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL  , Emails);

try {
    startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
    Toast.makeText(Vendor_home.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}

How to get value form server database with android

AndroidManifest

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

class YourClassName extends AsyncTask<String, String, String> {


    @Override    protected void onPreExecute() {
        super.onPreExecute();

        //put necessary code here 
    }

    /**     * loading data     */    protected String doInBackground(String... args) {


        // Building Parameters        List<NameValuePair> params = new ArrayList<NameValuePair>();


        params.add(new BasicNameValuePair("Your Key", Your value));
       
        // getting JSON Object
        JSONObject json = jsonParser.makeHttpRequest(url, "POST", params);

        // for checking        Log.d("Create Response", json.toString());

        // check for success tag        try {
            int success = json.getInt(SUCCESS);


            if (success == 1) {
                //get data to json array                your json array= json.getJSONArray(your key);
                //get length               

                for (int i = 0; i<jsonarray.length(); i++) {

                    //get jasonobject and store in arraylist                    JSONObject jsnobj = your_jason_array.getJSONObject(i);


                    String variable = jsnobj.getString(key);
                  


                }
            } else {

            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    /**     * After completing background task Dismiss the progress dialog     * *     */    protected void onPostExecute(String file_url) {
      
     

    }

} 



Sunday, November 1, 2015

How to call with android

AndroidManifest

<uses-permission android:name="android.permission.CALL_PHONE" />


Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + Your_Phone_Number));
startActivity(callIntent);

Wednesday, October 14, 2015

How to Insert value to server database with android

AndroidManifest


<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />


class Your_Method_Name extends AsyncTask<String, String, String> {

    /**     * Before starting background thread Show Progress Dialog     */    @Override    protected void onPreExecute() {
        super.onPreExecute();
        
    }

    /**     * adding messages     */    protected String doInBackground(String... args) {

        

        // Building Parameters        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("Your_Key", Your_value));
       

        // getting JSON Object
        JSONObject json = jsonParser.makeHttpRequest(url, "POST", params);

        //for checking        Log.d("Create Response", json.toString());

        // check for success tag        try {
            int success = json.getInt(SUCCESS);

            if (success == 1) {

            } else {

            }
        } catch (JSONException e) {

            e.printStackTrace();
        }

        return null;
    }

    /**     * After completing background task Dismiss the progress dialog     * *     */    protected void onPostExecute(String file_url) {

       
    }

}