我刚刚检查了 Application , 正在后台自动回复 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");
sendIntent.setPackage("com.whatsapp");
startActivity(sendIntent);
但是它打开了 WhatsApp 应用程序 :(,没有发送消息。
我浏览了几个链接:Question1 , Question2还有article但没有得到满意的答复。
application正在访问通知以获取消息并回复它,我还尝试使用 NotificationListenerService
读取通知,并成功读取消息:),但无法发送回复,我想知道他们如何在不打开应用程序的情况下在后台发送消息。
最佳答案
我还没有测试过这个,但我认为这可以通过 Read Notification Bar title, message using Accessibility Service Programmatically
和https://developer.android.com/reference/android/app/RemoteInput
来自文档:
public static final String KEY_QUICK_REPLY_TEXT = "quick_reply";
Notification.Action action = new Notification.Action.Builder(
R.drawable.reply, "Reply", actionIntent)
.addRemoteInput(new RemoteInput.Builder(KEY_QUICK_REPLY_TEXT)
.setLabel("Quick reply").build())
.build();
关于android - 在后台自动回复 WhatsApp 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50815024/