2 Commitit 29aa935801 ... 9aa40dfe2f

Tekijä SHA1 Viesti Päivämäärä
  Your Name 9aa40dfe2f Merge branch 'master' of http://git.quyaqu.com/xieshengqi/MoneyMoreMoreNote 7 vuotta sitten
  Your Name ebabca690a 提交 7 vuotta sitten

+ 13 - 5
app/src/main/java/com/kuxuan/moneynote/receiver/AlarmReceiver.java

@@ -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
 }

+ 17 - 0
app/src/main/res/layout/notification.xml

@@ -0,0 +1,17 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    android:orientation="horizontal"
4
+    android:gravity="center"
5
+    android:layout_width="match_parent"
6
+    android:layout_height="match_parent">
7
+<ImageView
8
+    android:layout_width="@dimen/len_32"
9
+    android:layout_marginStart="@dimen/len_8"
10
+    android:layout_height="@dimen/len_32"
11
+    android:src="@mipmap/app_icon"/>
12
+    <TextView
13
+        android:layout_width="match_parent"
14
+        android:layout_marginStart="@dimen/len_16"
15
+        android:layout_height="wrap_content"
16
+        android:text="记账时间到了,赶快去记账吧!"/>
17
+</LinearLayout>

BIN
app/src/main/res/mipmap-xhdpi/notificatioon.png