Procházet zdrojové kódy

优化通知栏显示效果
点击通知栏可以回到小绵羊之前的界面

zengjiebin před 7 roky
rodič
revize
da81d67c2b

+ 5 - 3
app/src/main/java/com/sheep/jiuyan/samllsheep/service/ListenerShotService.java

@@ -19,7 +19,7 @@ import com.sheep.gamegroup.util.ListUtil;
 import com.sheep.gamegroup.util.LogUtil;
 import com.sheep.gamegroup.util.RunningTaskUtil;
 import com.sheep.gamegroup.util.ScreenShotListenManager;
-import com.sheep.gamegroup.view.activity.ActMain;
+import com.sheep.gamegroup.view.activity.SplashAct;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.utils.FileUtil;
 
@@ -69,10 +69,12 @@ public class ListenerShotService extends Service {
         notification.contentView = new RemoteViews(getPackageName(), R.layout.notification_sheep_shot_screen);
 
         //点击通知栏跳转到相应的应用里面
-        Intent intent = new Intent(this, ActMain.class);
+        Intent notificationIntent = new Intent(this, SplashAct.class);
+        notificationIntent.setAction(Intent.ACTION_MAIN);
+        notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
         //这一句加不加没什么影响
 // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        notification.contentIntent = PendingIntent.getActivity(this, 1, intent, 0);
+        notification.contentIntent = PendingIntent.getActivity(this, 1, notificationIntent, 0);
 
         //这里的id不能是0
         startForeground(113922, notification);

+ 10 - 8
app/src/main/res/layout/notification_sheep_shot_screen.xml

@@ -2,19 +2,21 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:gravity="center">
+    android:gravity="center_vertical"
+    android:orientation="horizontal"
+    android:padding="13dp">
 
     <ImageView
-        android:layout_width="40dp"
-        android:layout_height="40dp"
-        android:layout_marginStart="20dp"
+        android:layout_width="35dp"
+        android:layout_height="35dp"
         android:src="@mipmap/icon" />
 
     <TextView
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="15dp"
         android:gravity="center"
         android:text="点击回到小绵羊"
-        android:textColor="@color/black_333333"
-        android:textSize="18sp" />
+        android:textColor="@color/white"
+        android:textSize="16sp" />
 </LinearLayout>