0

I've tried this it seems to be working for everyone but not for me. If you want to extra information inform me and i'll add it.

My Code:

import android.net.Uri;
import android.os.Bundle;
import android.provider.Contacts;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.database.Cursor;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import com.actionbarsherlock.ActionBarSherlock;
import com.actionbarsherlock.ActionBarSherlock.OnCreateOptionsMenuListener;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.MenuInflater;

public class MainActivity extends SherlockActivity {

I get The method getSherlockActivity() is undefined for the type new View.OnClickListener(){} From this code:

Cursor c = getSherlockActivity().getContentResolver().query(ContactsContract.Data.CONTENT_URI,
                    new String[] { ContactsContract.Contacts.Data._ID }, ContactsContract.Data.DATA1 + "=?",
                        new String[] { "96XXXXXXX@s.whatsapp.net" }, null);
                c.moveToFirst();
                Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("content://com.android.contacts/data/" + c.getString(0)));

                startActivity(i);
                c.close();

Thanks in advance.

Community
  • 1
  • 1
SamJ
  • 413
  • 1
  • 4
  • 18

1 Answers1

1

Just change getSherlockActivity to this keyword and you code will work fine. However it will only open whatsapp chat window and not send the message automatically.

azmuhak
  • 964
  • 1
  • 11
  • 31