添加通知栏清理功能
This commit is contained in:
		| @@ -1,8 +1,8 @@ | |||||||
| #Created by .winboll/winboll_app_build.gradle | #Created by .winboll/winboll_app_build.gradle | ||||||
| #Tue May 06 11:17:44 HKT 2025 | #Tue May 06 03:25:35 GMT 2025 | ||||||
| stageCount=1 | stageCount=1 | ||||||
| libraryProject= | libraryProject= | ||||||
| baseVersion=15.0 | baseVersion=15.0 | ||||||
| publishVersion=15.0.0 | publishVersion=15.0.0 | ||||||
| buildCount=0 | buildCount=2 | ||||||
| baseBetaVersion=15.0.1 | baseBetaVersion=15.0.1 | ||||||
|   | |||||||
| @@ -6,6 +6,7 @@ package cc.winboll.studio.timestamp; | |||||||
|  * @Describe 主要服务 |  * @Describe 主要服务 | ||||||
|  */ |  */ | ||||||
| import android.app.Notification; | import android.app.Notification; | ||||||
|  | import android.app.NotificationManager; | ||||||
| import android.app.Service; | import android.app.Service; | ||||||
| import android.content.ComponentName; | import android.content.ComponentName; | ||||||
| import android.content.Context; | import android.content.Context; | ||||||
| @@ -128,6 +129,9 @@ public class MainService extends Service { | |||||||
|         if (mTimer != null) { |         if (mTimer != null) { | ||||||
|             mTimer.cancel(); |             mTimer.cancel(); | ||||||
|         } |         } | ||||||
|  |          | ||||||
|  |         NotificationManager notificationManager = getSystemService(NotificationManager.class); | ||||||
|  |         notificationManager.cancelAll(); | ||||||
|  |  | ||||||
|         _mIsServiceAlive = false; |         _mIsServiceAlive = false; | ||||||
|         LogUtils.d(TAG, "onDestroy()"); |         LogUtils.d(TAG, "onDestroy()"); | ||||||
|   | |||||||
| @@ -15,6 +15,7 @@ import android.widget.TextView; | |||||||
| import androidx.core.app.NotificationCompat; | import androidx.core.app.NotificationCompat; | ||||||
| import cc.winboll.studio.timestamp.R; | import cc.winboll.studio.timestamp.R; | ||||||
| import cc.winboll.studio.timestamp.receivers.ButtonClickReceiver; | import cc.winboll.studio.timestamp.receivers.ButtonClickReceiver; | ||||||
|  | import android.app.Notification; | ||||||
|  |  | ||||||
| public class TimeStampRemoteViewsUtil { | public class TimeStampRemoteViewsUtil { | ||||||
|  |  | ||||||
| @@ -26,6 +27,7 @@ public class TimeStampRemoteViewsUtil { | |||||||
|     Context mContext; |     Context mContext; | ||||||
|     RemoteViews mRemoteViews; |     RemoteViews mRemoteViews; | ||||||
|     TextView mtvMessage; |     TextView mtvMessage; | ||||||
|  |     Notification mNotification; | ||||||
|  |  | ||||||
|     TimeStampRemoteViewsUtil(Context context) { |     TimeStampRemoteViewsUtil(Context context) { | ||||||
|         mContext = context; |         mContext = context; | ||||||
| @@ -91,6 +93,7 @@ public class TimeStampRemoteViewsUtil { | |||||||
|  |  | ||||||
|         // 显示通知 |         // 显示通知 | ||||||
|         NotificationManager notificationManager = mContext.getSystemService(NotificationManager.class); |         NotificationManager notificationManager = mContext.getSystemService(NotificationManager.class); | ||||||
|         notificationManager.notify(1, builder.build()); |         mNotification = builder.build(); | ||||||
|  |         notificationManager.notify(1, mNotification); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 ZhanGSKen
					ZhanGSKen