having passed my code, I found out that you are trying to get the contact name from a number. and with this you want to get the contact image .. but you never called the functions that you created for the contact pic .. :) .. so what you can do is take the id from the contact number and take a picture on that id . so you get a photo for the room ..
package com.android.SampleProject; import java.io.ByteArrayInputStream; import java.io.InputStream; import android.app.Activity; import android.content.ContentResolver; import android.content.ContentUris; import android.content.Context; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.net.Uri; import android.os.Bundle; import android.provider.ContactsContract; import android.provider.ContactsContract.Contacts; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.Toast; public class NewtempActivity extends Activity { private long id; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final ImageView img = (ImageView) findViewById(R.id.imageView1); final EditText edit = (EditText) findViewById(R.id.editText1); Button btn = (Button) findViewById(R.id.button1); btn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Log.d("Girish", "Clicked"); String name = getContactNameFromNumber(edit.getText() .toString(), getApplicationContext()); img.setImageBitmap(BitmapFactory .decodeFile(ContactsContract.PhoneLookup._ID)); img.setImageBitmap(loadContactPhoto(getContentResolver(), id)); Log.d("Girish", "" + (BitmapFactory .decodeFile(ContactsContract.PhoneLookup._ID))); Toast.makeText(getApplicationContext(), name, name.length()) .show(); } }); } public String getContactNameFromNumber(String number, Context ctx) {
source share