Post Android getting SMS body from inbox

I want to get body of SMS when I click on one. I have tried an approach simmilar to contact picker. Here is my code :

public class Decrypt extends Fragment {
Button loadButton;
EditText smsDisplay;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
View v = inflater.inflate(R.layout.decrypt, null);
// Button loadButton=(Button)v.findViewById(
loadButton=(Button)v.findViewById( ;
smsDisplay=(EditText)v.findViewById( oad);
loadButton.setOnClickListener(new OnClickListener() {

public void onClick(View v) {

Intent sendIntent = new Intent(Intent.ACTION_VIEW);


return v;


public void onActivityResult(int requestCode, int resultCode, Intent data) {
// if (resultCode == Activity.RESULT_OK) {
Uri ur = data.getData();
Cursor c = getActivity().getContentResolver().query(ur, null, null, null, null);
if (c.moveToFirst()) {
String s = c.getString(c.getColumnIndex("body"));
Toast.makeText(getActivity(), s, Toast.LENGTH_LONG).show();
}catch(Exception e){
// }

It opens a Inbox like when I open original sms app in anroid, but when I click on one message it doesnt copy body of that sms in my edittext. Please couul you look at my code and find mistake?

Thanks a lot for your time