Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialsean tatenda jack
6,127 PointsNext we want to build the notification with an icon, title, and text. Set the icon to R.drawable.ic_distress, the titl
please help, i can't get trough past challenge 2.
Next we want to build the notification with an icon, title, and text. Set the icon to R.drawable.ic_distress, the title to "Incoming Distress Signal", and the text as "A distress call has been received from somewhere in space and time."
public class DistressCallReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// Add your code here!
Notification.Builder notif = new Notification.Builder(context);
notif.setSmallIcon(R.drawable.ic_distress);
notif.setContentTitle("Incoming Distress Signal");
notif.setContentText("A distress call has been recieved from somewhere in space and time".);
Notification notification = notificationBuilder.build();
}
}
3 Answers
Helen Mehari
Courses Plus Student 1,426 PointsHello You had a . outside the string and you have to build the notification as I have dont in my last line of code.
Notification.Builder notif = new Notification.Builder(context);
notif.setSmallIcon(R.drawable.ic_distress);
notif.setContentTitle("Incoming Distress Signal");
notif.setContentText("A distress call has been received from somewhere in space and time.");
notif.build();
Helen Mehari
Courses Plus Student 1,426 PointsIt also did the same thing to me. Try copying the text inside the " quotes and replace the ones on the code. May be I have misspelled some Words.
Urgent Nkala
8,772 Pointsspelling of receive not recieve that is making you have a Bummer!under " " the correct line is "A distress call has been received from somewhere in space and time."
sean tatenda jack
6,127 Pointssean tatenda jack
6,127 PointsHie Helen.
Sorry for bothering. i've tried you code like this but not passing. giving a (make sure you use the text specified in the instruction)
Bummer! Make sure you use the text specified in the instructions! Restart Preview Get Help Recheck work DistressCallReceiver.java
public class DistressCallReceiver extends BroadcastReceiver {
}