发送消息到特定号码(WhatsApp的) [英] Sending message to specific Number(Whatsapp)

查看:148
本文介绍了发送消息到特定号码(WhatsApp的)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过<一个href=\"http://stackoverflow.com/questions/17768688/sending-message-through-whatsapp-by-intent\">this它似乎是工作适合所有人,但不适合我。
如果你想额外的信息告诉我,我会添加它。

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.

我的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 {

我得到的的方法getSherlockActivity()是未定义的类型新View.OnClickListener(){} 此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();

先谢谢了。

推荐答案

只要改变 getSherlockActivity 这个关键字和您code将正常工作。然而,它只会打开WhatsApp的聊天窗口,并不会自动发送该邮件。

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.

这篇关于发送消息到特定号码(WhatsApp的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆