|
@@ -5,11 +5,16 @@ import android.app.NotificationManager;
|
5
|
5
|
import android.content.BroadcastReceiver;
|
6
|
6
|
import android.content.Context;
|
7
|
7
|
import android.content.Intent;
|
|
8
|
+import android.graphics.Bitmap;
|
|
9
|
+import android.graphics.BitmapFactory;
|
8
|
10
|
import android.support.v7.app.NotificationCompat;
|
9
|
11
|
import android.util.Log;
|
|
12
|
+import android.widget.RemoteViews;
|
10
|
13
|
|
11
|
14
|
import com.kuxuan.moneynote.R;
|
12
|
15
|
|
|
16
|
+import static com.umeng.socialize.utils.ContextUtil.getPackageName;
|
|
17
|
+
|
13
|
18
|
/**
|
14
|
19
|
* @author HFRX hfrx1314@qq.com
|
15
|
20
|
* @version 1.0.0
|
|
@@ -19,19 +24,22 @@ public class AlarmReceiver extends BroadcastReceiver {
|
19
|
24
|
private static final String TAG = "AlarmReceiver";
|
20
|
25
|
@Override
|
21
|
26
|
public void onReceive(Context context, Intent intent) {
|
22
|
|
-
|
|
27
|
+ Bitmap bmp= BitmapFactory.decodeResource(context.getResources(), R.mipmap.app_icon);
|
23
|
28
|
Log.e(TAG,"闹钟已响");
|
24
|
29
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
|
25
|
|
- builder.setSmallIcon(R.mipmap.app_icon);
|
26
|
|
- builder.setContentTitle("钱多多记账");
|
27
|
|
- builder.setContentText("记账时间到了,赶快去记账吧");
|
|
30
|
+ builder.setSmallIcon(R.mipmap.ic_launcher);
|
|
31
|
+ RemoteViews contentView = new RemoteViews(getPackageName(),R.layout.notification);
|
|
32
|
+ builder.setContent(contentView);
|
28
|
33
|
builder.setAutoCancel(true);
|
29
|
|
- builder.setOnlyAlertOnce(true);
|
30
|
34
|
// 需要VIBRATE权限
|
31
|
35
|
builder.setDefaults(Notification.DEFAULT_VIBRATE);
|
32
|
36
|
builder.setPriority(Notification.PRIORITY_DEFAULT);
|
33
|
37
|
NotificationManager notificationManager = (NotificationManager) context
|
34
|
38
|
.getSystemService(Context.NOTIFICATION_SERVICE);
|
35
|
39
|
notificationManager.notify(111, builder.build());
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
36
|
44
|
}
|
37
|
45
|
}
|