Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void getSmsLogs(Cursor c, Context con) {
- if (sms_num.size() > 0) {
- sms_id.clear();
- sms_num.clear();
- sms_Name.clear();
- sms_body.clear();
- sms_dt.clear();
- }
- ListView lv = (ListView)messview.findViewById(R.id.listView);
- ArrayAdapter<String> adapter = null;
- try {
- if (c.moveToLast()) {
- do {
- if (c.getString(c.getColumnIndexOrThrow("address")) == null) {
- c.moveToNext();
- continue;
- }
- String Number = c.getString(
- c.getColumnIndexOrThrow("address")).toString();
- Log.e("Number-->", "" + Number);
- // if (Number.equalsIgnoreCase("+918000912692")) {
- String _id = c.getString(c.getColumnIndexOrThrow("_id"))
- .toString();
- String dat = c.getString(c.getColumnIndexOrThrow("date"))
- .toString();
- // String as = (String) get_dt(dat,
- // "dd/MM/yyyy, hh.mma");
- String Body = c.getString(c.getColumnIndexOrThrow("body"))
- .toString();
- // if (name.length() <= 0 || name.length() == 1) {
- // name = "no name";
- // }
- try {
- if (c.getString(c.getColumnIndexOrThrow("type")).toString().contains("1")) {
- Context context = getApplicationContext();
- CharSequence text = c.getString(c.getColumnIndexOrThrow("type")).toString();
- int duration = Toast.LENGTH_SHORT;
- Toast toast = Toast.makeText(context, text, duration);
- toast.show();
- adapter = new ArrayAdapter<String>(this, R.layout.incomming, R.id.message, sms_body);
- lv.setAdapter(adapter);
- } else {
- adapter = new ArrayAdapter<String>(this, R.layout.outgoing, R.id.message, sms_body);
- lv.setAdapter(adapter);
- }
- } catch (Exception ex) {
- Context context = getApplicationContext();
- CharSequence text = ex.toString();
- int duration = Toast.LENGTH_SHORT;
- Toast toast = Toast.makeText(context, text, duration);
- toast.show();
- }
- Log.e("Body-->", "" + Body);
- sms_id.add(_id);
- sms_num.add(Number);
- sms_body.add(Body);
- } while (c.moveToPrevious());
- lv.setSelection(lv.getCount() - +1);
- }
- c.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement