Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在android中使用NotificationListener服务回复通知_Java_Android_Notifications - Fatal编程技术网

Java 如何在android中使用NotificationListener服务回复通知

Java 如何在android中使用NotificationListener服务回复通知,java,android,notifications,Java,Android,Notifications,我正在开发一个android应用程序,我需要从whatsapp或任何其他聊天应用程序获取传入消息,然后使用我的应用程序回复该消息 我可以使用NotificationListener服务从通知中提取消息和其他数据,但我不知道如何从我的应用程序中回复该通知 我使用NotificationListener类的以下方法获得了所有信息 @Override public void onNotificationPosted(StatusBarNotification sbn) { super.onN

我正在开发一个android应用程序,我需要从whatsapp或任何其他聊天应用程序获取传入消息,然后使用我的应用程序回复该消息

我可以使用NotificationListener服务从通知中提取消息和其他数据,但我不知道如何从我的应用程序中回复该通知

我使用NotificationListener类的以下方法获得了所有信息

 @Override
public void onNotificationPosted(StatusBarNotification sbn) {
    super.onNotificationPosted(sbn);

    Intent intent = new Intent(this, ChatHeadService.class);
    startService(intent);
    bindService(intent, mConnection, Context.BIND_AUTO_CREATE);

    String key = sbn.getKey();    // notification key
    PendingIntent intent1 = sbn.getNotification().contentIntent;  // pending intent
    String pack = sbn.getPackageName();     // package name of app
    Bundle noti = sbn.getNotification().extras;      // extra bundle of notification
    String name = noti.getString("android.title");   // name of the sender
    Bitmap img = sbn.getNotification().largeIcon;   // the icon of the sender user
    CharSequence[] textlines = noti.getCharSequenceArray("android.textLines");
    if (textlines != null)
        Log.i("textlines", textlines.toString());

现在我需要回复上述通知

到目前为止,你做了什么?@Badda如问题中所述,我收到了来自notification@Badda现在我只想回复相同的通知,而不打开app@Badda当然我将更新我的问题并发布code@Badda我已经更新了问题并添加了代码。。