-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8162852
commit 20bd633
Showing
3 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
app/src/main/java/io/github/adamjodlowski/notifications/ReplyReceiver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.github.adamjodlowski.notifications; | ||
|
||
import android.app.NotificationManager; | ||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v4.app.NotificationCompat; | ||
import android.support.v4.app.RemoteInput; | ||
|
||
import static android.content.Context.NOTIFICATION_SERVICE; | ||
import static io.github.adamjodlowski.notifications.MainActivity.NOTIFICATION_ID; | ||
|
||
public class ReplyReceiver extends BroadcastReceiver { | ||
public ReplyReceiver() { | ||
} | ||
|
||
@Override | ||
public void onReceive(Context context, Intent intent) { | ||
Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); | ||
if (remoteInput != null) { | ||
|
||
CharSequence id = remoteInput.getCharSequence(MainActivity.KEY_NOTIFICATION_REPLY); | ||
|
||
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) | ||
.setSmallIcon(android.R.drawable.ic_dialog_info) | ||
.setContentTitle("Request received for ID: " + id); | ||
|
||
NotificationManager notificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE); | ||
notificationManager.notify(NOTIFICATION_ID, mBuilder.build()); | ||
} | ||
} | ||
} |