1 |
|
package com.dreamcatcher.bicycle.util; |
2 |
|
|
3 |
|
import android.app.Notification; |
4 |
|
import android.app.NotificationManager; |
5 |
|
import android.app.PendingIntent; |
6 |
|
import android.content.Context; |
7 |
|
import android.content.Intent; |
8 |
|
|
9 |
|
import com.dreamcatcher.bicycle.BicycleApp; |
10 |
|
import com.dreamcatcher.bicycle.R; |
11 |
|
import com.dreamcatcher.bicycle.activity.Main; |
12 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 1 |
Complexity Density: 0,07 |
|
13 |
|
public class ReminderNotification { |
14 |
|
private final static int REMINDER_ID = 1; |
15 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 1 |
Complexity Density: 0,07 |
|
16 |
0
|
public static void startNotification(){... |
17 |
0
|
BicycleApp bicycleApp = BicycleApp.getInstance(); |
18 |
|
|
19 |
0
|
NotificationManager notificationManager = (NotificationManager)bicycleApp.getSystemService(Context.NOTIFICATION_SERVICE); |
20 |
|
|
21 |
0
|
int icon = R.drawable.ic_reminder_return_bicycle; |
22 |
0
|
CharSequence tickerText = Utils.getText(R.string.notification_ticket_text); |
23 |
0
|
long when = System.currentTimeMillis(); |
24 |
0
|
Notification notification = new Notification(icon, tickerText, when); |
25 |
|
|
26 |
0
|
CharSequence contentTitle = Utils.getText(R.string.notification_content_title); |
27 |
0
|
CharSequence contentText = Utils.getText(R.string.notification_content_text); |
28 |
|
|
29 |
0
|
Intent notificationIntent = new Intent(bicycleApp, Main.class); |
30 |
|
|
31 |
0
|
notificationIntent.putExtra(Constants.IntentExtraTag.MAIN_REMINDER_FROM_NOTIFICATION, true); |
32 |
|
|
33 |
0
|
PendingIntent contentIntent = PendingIntent.getActivity(bicycleApp, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); |
34 |
|
|
35 |
|
|
36 |
0
|
notification.flags = Notification.FLAG_AUTO_CANCEL; |
37 |
0
|
notification.setLatestEventInfo(bicycleApp, contentTitle, contentText, contentIntent); |
38 |
|
|
39 |
0
|
notificationManager.notify(REMINDER_ID, notification); |
40 |
|
} |
41 |
|
} |