JulianTH
- Forum-Beiträge: 12
04.04.2013, 19:11:29 via Website
04.04.2013 19:11:29 via Website
Hallo,
ich weiß, dass es bereits 1-2 Threads dazu gibt...
aber ich bin da doch noch ein bisschen planlos.
Ich möchte gerne meinen RSS Reader erweitern mit Benachrichtungen, falls es einen neuen RSS Feed gibt.
Wie man eine Notifications erstellt leuchtet mir anhand dieses Codes ein:
Ab dann bin ich allerdings ratlos... . Mir fehlt quasi der Schritt "Neuer Feed ---> Notification"
Vielleicht kann mir jemand helfen?
Lg
ich weiß, dass es bereits 1-2 Threads dazu gibt...
aber ich bin da doch noch ein bisschen planlos.
Ich möchte gerne meinen RSS Reader erweitern mit Benachrichtungen, falls es einen neuen RSS Feed gibt.
Wie man eine Notifications erstellt leuchtet mir anhand dieses Codes ein:
1public class NotificationActivity extends Activity {
2 @Override
3 public void onCreate(Bundle savedInstanceState) {
4 super.onCreate(savedInstanceState);
5 setContentView(R.layout.main);
6 }
7
8 public void createNotification(View view) {
9 // Prepare intent which is triggered if the
10 // notification is selected
11 Intent intent = new Intent(this, NotificationReceiverActivity.class);
12 PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
13
14 // Build notification
15 // Actions are just fake
16 Notification noti = new Notification.Builder(this)
17 .setContentTitle("New mail from " + "test@gmail.com")
18 .setContentText("Subject").setSmallIcon(R.drawable.icon)
19 .setContentIntent(pIntent)
20 .addAction(R.drawable.icon, "Call", pIntent)
21 .addAction(R.drawable.icon, "More", pIntent)
22 .addAction(R.drawable.icon, "And more", pIntent).build();
23 NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
24 // Hide the notification after its selected
25 noti.flags |= Notification.FLAG_AUTO_CANCEL;
26
27 notificationManager.notify(0, noti);
28
29 }
30}
2 @Override
3 public void onCreate(Bundle savedInstanceState) {
4 super.onCreate(savedInstanceState);
5 setContentView(R.layout.main);
6 }
7
8 public void createNotification(View view) {
9 // Prepare intent which is triggered if the
10 // notification is selected
11 Intent intent = new Intent(this, NotificationReceiverActivity.class);
12 PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
13
14 // Build notification
15 // Actions are just fake
16 Notification noti = new Notification.Builder(this)
17 .setContentTitle("New mail from " + "test@gmail.com")
18 .setContentText("Subject").setSmallIcon(R.drawable.icon)
19 .setContentIntent(pIntent)
20 .addAction(R.drawable.icon, "Call", pIntent)
21 .addAction(R.drawable.icon, "More", pIntent)
22 .addAction(R.drawable.icon, "And more", pIntent).build();
23 NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
24 // Hide the notification after its selected
25 noti.flags |= Notification.FLAG_AUTO_CANCEL;
26
27 notificationManager.notify(0, noti);
28
29 }
30}
Ab dann bin ich allerdings ratlos... . Mir fehlt quasi der Schritt "Neuer Feed ---> Notification"
Vielleicht kann mir jemand helfen?
Lg
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.