Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public View getView(final int position, View convertView, ViewGroup parent) {
- View rowView = convertView;
- final ViewHolder holder;
- if (rowView == null) {
- ....
- ....
- ....
- // RETRIEVE LATEST SMS FROM CONTACTS WHO SENT SMS
- String folder = "content://sms/inbox/";
- Uri mSmsQueryUri = Uri.parse(folder);
- messages = new ArrayList<String>();
- contactID = new ArrayList<String>();
- try {
- c = context.getContentResolver().query(mSmsQueryUri,
- new String[] { "_id", "address", "date", "body" },
- null, null, null);
- if (c == null) {
- Log.i(TAG, "cursor is null. uri: " + mSmsQueryUri);
- }
- c.moveToFirst();
- while (c.moveToNext()) {
- body = c.getString(3);
- phoneNumber = c.getString(1);
- contactID.add(phoneNumber + "\n" + " " + body);
- }
- c.moveToFirst();
- while (c.moveToNext()) {
- body = c.getString(3);
- phoneNumber = c.getString(1);
- messages.add(phoneNumber + " " + body);
- }
- } catch (Exception e) {
- Log.e(TAG, e.getMessage());
- } finally {
- c.close();
- }
- holder.latestSMS.setText(messages.get(position); // Display text message segment
- } else {
- holder = (ViewHolder) rowView.getTag();
- }
- if (holder != null) {
- // bind the data to the row views
- String testing = contactNo.get(position); // Display phone number
- }
- } // end getView
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement