自动回复whatsapp消息的方法 [英] Automatic reply for whatsapp messages approach
问题描述
我在Play商店上看到很少有支持自动回复WhatsApp的应用程序,我在互联网上搜索了该方法,但是我发现的只是这段代码
I have seen few applications on play store that supports automatic reply for WhatsApp, I searched the internet to find out the approach, but all I found was this piece of code
Uri uri = Uri.parse("smsto:" + "99********");
Intent i = new Intent(Intent.ACTION_SENDTO, uri);
i.putExtra("sms_body", "Hey!");
i.setPackage("com.whatsapp");
startActivity(i);
如果已保存,它将打开WhatsApp并带您到该特定联系人,并且它将粘贴给定的文本,但不会发送消息.
It will open the WhatsApp and take you to that particular contact if you have saved and it will paste the given text but it will not send the message.
链接
https://play.google.com/store/apps/details?id=horizontstack.autoreplyforwhatsapp.whatsreply
他们正在访问通知以获取消息.我想知道他们如何在不打开应用程序的情况下在后台发送消息.如果有人知道该方法,请在这里分享.
They are accessing the notifications to get the messages. I want to know how they are sending the messages in the background without opening the application. If somebody knows the approach please share here.
推荐答案
我这样做的是:
步骤1:从 NotificationHelperLibrary 存储库中复制所有代码.
步骤2:创建Notification Listener Service,并将以下代码放入onNotificationPosted(..)
方法中:
Step 1: copy all code from NotificationHelperLibrary repository.
Step 2: Create Notification Listener Service and put below code in onNotificationPosted(..)
method:
MyNotifiService.this.cancelNotification(sbn.getKey());
Action action = NotificationUtils.getQuickReplyAction(sbn.getNotification(), getPackageName());
if (action != null) {
Log.i(TAG, "success");
try {
action.sendReply(getApplicationContext(), "Hello");
} catch (PendingIntent.CanceledException e) {
Log.i(TAG, "CRAP " + e.toString());
}
} else {
Log.i(TAG, "not success");
}
这是基本演示.
这篇关于自动回复whatsapp消息的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!