Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.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 如何将文本作为输入,然后在通过单击按钮生成的通知中显示它?_Java_Android_Notifications - Fatal编程技术网

Java 如何将文本作为输入,然后在通过单击按钮生成的通知中显示它?

Java 如何将文本作为输入,然后在通过单击按钮生成的通知中显示它?,java,android,notifications,Java,Android,Notifications,我正在制作一个android应用程序,用户将在其中输入文本并单击按钮。单击按钮后,将显示通知,通知应显示用户输入的文本 按下按钮时,从编辑文本中获取文本 在按钮的OnClick方法中 通过以下代码生成通知: // build notification String content = edtEditText.getText().toString(); Notification n = new Notification.Builder(this) .setContentT

我正在制作一个android应用程序,用户将在其中输入文本并单击按钮。单击按钮后,将显示通知,通知应显示用户输入的文本

按下按钮时,从编辑文本中获取文本

在按钮的OnClick方法中

通过以下代码生成通知:

// build notification
String content = edtEditText.getText().toString();
Notification n  = new Notification.Builder(this)
            .setContentTitle("Title That you want")
            .setContentText(content).build();


NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);

notificationManager.notify(0, n);
请参阅此链接以生成通知

Stackoverflow不会为您编写代码。你试过跟踪这个吗?