Android 如何在不打开whatsapp的情况下,以编程方式将数据从textView发送到特定的whatsapp号码?

Android 如何在不打开whatsapp的情况下,以编程方式将数据从textView发送到特定的whatsapp号码?,android,android-intent,textview,whatsapp,Android,Android Intent,Textview,Whatsapp,我收集了3条信息:姓名、地址、产品 我想把它们发送到一个特定的whatsapp号码,号码总是一样的,我想把数据最好发送到whatsapp内部的聊天室 TextView name = (TextView)findViewById(R.id.name); TextView address = (TextView)findViewById(R.id.address); TextView product = (TextView)findViewById(R.id.product); 网站上的whats

我收集了3条信息:姓名、地址、产品

我想把它们发送到一个特定的whatsapp号码,号码总是一样的,我想把数据最好发送到whatsapp内部的聊天室

TextView name = (TextView)findViewById(R.id.name);
TextView address = (TextView)findViewById(R.id.address);
TextView product = (TextView)findViewById(R.id.product);
网站上的whatsapp常见问题解答提供了以下代码:

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
startActivity(sendIntent);

sendIntent.setPackage("com.whatsapp");
指定数据应该指向的数字的位置在哪里

我希望订单数据直接进入一个特定的聊天室,到一个特定的电话号码,如+77056748392


不仅仅是打开whatsapp共享!我怀疑Whatsapp API没有此功能?

您需要自己格式化

String sendString = "Name: " + name + "\nAddress: " + address + "\nProduct: " + product; 
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, sendString);
sendIntent.setType("text/plain");
sendIntent.setPackage("com.whatsapp");
startActivity(sendIntent);
现在,信息如下:

Name : Erwin
Address: LA-36, USA
Product: T-shirt
如果您想使用特定号码打开whatsapp,可以执行以下操作:

Uri uri = Uri.parse("smsto:" + phoneNumber);
                Intent i = new Intent(Intent.ACTION_SENDTO, uri);
                i.setPackage("com.whatsapp");

但不知道如何在第二个选项中发送数据:)

thx,但这不会直接将消息发送到whatsapp号码,对吗?这将只打开whatsapp进行共享?我想让它直接转到一个特定的聊天室到一个特定的号码