0

I'm trying to implement a way in which the "client" can apply to certain jobs I post.

I got the display and the database, and what I'm trying to do now is to make a button that automatically sends an email with the job the client has chosen, after he presses the Submit button.

The app also has a login function with : name, email and phone number

My question is: How can I send an email using the clients name (which I take from the database), and in the same mail have the name of the job that he chose?

This is what I have so far:

@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {


    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    db = (new DBResep(this)).getWritableDatabase();
    lv = (ListView) findViewById(R.id.lv);
    et_db = (AutoCompleteTextView) findViewById(R.id.et);
    et_db2 = (AutoCompleteTextView) findViewById(R.id.et2);





    try {
        cursor = db.rawQuery("SELECT * FROM resep ORDER BY name ASC", null);
        adapter = new SimpleCursorAdapter(this, R.layout.isi_lv, cursor,
                new String[]{"name", "oras", "img"}, new int[]{
                R.id.tv_name, R.id.tvOras, R.id.imV});
        lv.setAdapter(adapter);
        lv.setTextFilterEnabled(true);
        lv.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View v,
                                    int position, long id) {
                detail(position);

            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
    ArrayAdapter<String> adapter = new ArrayAdapter<String>
            (this, android.R.layout.select_dialog_item, arr);
    //Getting the instance of AutoCompleteTextView
    AutoCompleteTextView actv = (AutoCompleteTextView) findViewById(R.id.et2);
    actv.setThreshold(0);//will start working from first character
    actv.setAdapter(adapter);//setting the adapter data into the AutoCompleteTextView

    ArrayAdapter<String> adapter2 = new ArrayAdapter<String>
            (this, android.R.layout.select_dialog_item, arr2);
    //Getting the instance of AutoCompleteTextView
    AutoCompleteTextView actv2 = (AutoCompleteTextView) findViewById(R.id.et);
    actv2.setThreshold(0);//will start working from first character
    actv2.setAdapter(adapter2);//setting the adapter data into the AutoCompleteTextView
}

@SuppressWarnings("deprecation")
public void search_db(View v) {
    String edit_db = et_db.getText().toString();
    if (!edit_db.equals("")) {
        try {
            cursor = db.rawQuery("SELECT * FROM resep WHERE tara LIKE ?",
                    new String[] { "%" + edit_db + "%" });
            adapter = new SimpleCursorAdapter(
                    this,
                    R.layout.isi_lv,
                    cursor,
                    new String[] { "name", "oras", "img" },
                    new int[] { R.id.tv_name, R.id.tvOras, R.id.imV });
            if (adapter.getCount() == 0) {
                Toast.makeText(
                        this,
                        "We couldn't find any project in that country " + edit_db
                                + "", Toast.LENGTH_SHORT).show();
            } else {
                lv.setAdapter(adapter);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else {
        try {
            cursor = db.rawQuery("SELECT * FROM resep ORDER BY name ASC",
                    null);
            adapter = new SimpleCursorAdapter(
                    this,
                    R.layout.isi_lv,
                    cursor,
                    new String[] { "name", "oras", "img" },
                    new int[] { R.id.tv_name, R.id.tvOras, R.id.imV });
            lv.setAdapter(adapter);
            lv.setTextFilterEnabled(true);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


@SuppressWarnings("deprecation")
public void search_db2(View v) {
    String edit_db = et_db2.getText().toString();
    if (!edit_db.equals("")) {
        try {
            cursor = db.rawQuery("SELECT * FROM resep WHERE luna LIKE ?",
                    new String[] { "%" + edit_db + "%" });
            adapter = new SimpleCursorAdapter(
                    this,
                    R.layout.isi_lv,
                    cursor,
                    new String[] { "name", "oras", "img" },
                    new int[] { R.id.tv_name, R.id.tvOras, R.id.imV });
            if (adapter.getCount() == 0) {
                Toast.makeText(
                        this,
                        "We couldn't find any project in  " + edit_db
                                + "", Toast.LENGTH_SHORT).show();
            } else {
                lv.setAdapter(adapter);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    } 





public void detail(int position) {
    int im = 0;
    String _id = "";
    String name = "";
    String oras = "";
    String desc = "";
    String durata = "";
    String facil = "";
    if (cursor.moveToFirst()) {
        cursor.moveToPosition(position);
        im = cursor.getInt(cursor.getColumnIndex("img"));
        name = cursor.getString(cursor.getColumnIndex("name"));
        oras = cursor.getString(cursor.getColumnIndex("oras"));
        desc = cursor.getString(cursor.getColumnIndex("desc"));
        durata = cursor.getString(cursor.getColumnIndex("durata"));
        facil = cursor.getString(cursor.getColumnIndex("facil"));
    }

    Intent iIntent = new Intent(this, DB_Parse.class);
    iIntent.putExtra("dataIM", im);
    iIntent.putExtra("dataName", name);
    iIntent.putExtra("dataoras", oras);
    iIntent.putExtra("datadesc", desc);
    iIntent.putExtra("dataDurata", durata);
    iIntent.putExtra("dataFacil", facil);
    setResult(RESULT_OK, iIntent);
    startActivityForResult(iIntent, 99);
}

}

armatita
  • 12,825
  • 8
  • 48
  • 49
Boghy Dickenson
  • 193
  • 1
  • 1
  • 9

0 Answers0