Compare commits
5 Commits
timestamp-
...
timestamp-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df6633046c | ||
|
|
7d35d5a9b8 | ||
|
|
ddce5646bd | ||
|
|
3607a99053 | ||
|
|
6a101d8843 |
@@ -0,0 +1 @@
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Tue May 06 11:17:44 HKT 2025
|
||||
stageCount=1
|
||||
#Tue May 06 11:34:02 HKT 2025
|
||||
stageCount=3
|
||||
libraryProject=
|
||||
baseVersion=15.0
|
||||
publishVersion=15.0.0
|
||||
publishVersion=15.0.2
|
||||
buildCount=0
|
||||
baseBetaVersion=15.0.1
|
||||
baseBetaVersion=15.0.3
|
||||
|
||||
@@ -6,6 +6,7 @@ package cc.winboll.studio.timestamp;
|
||||
* @Describe 主要服务
|
||||
*/
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.Service;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
@@ -128,6 +129,9 @@ public class MainService extends Service {
|
||||
if (mTimer != null) {
|
||||
mTimer.cancel();
|
||||
}
|
||||
|
||||
NotificationManager notificationManager = getSystemService(NotificationManager.class);
|
||||
notificationManager.cancelAll();
|
||||
|
||||
_mIsServiceAlive = false;
|
||||
LogUtils.d(TAG, "onDestroy()");
|
||||
|
||||
@@ -5,14 +5,17 @@ package cc.winboll.studio.timestamp.utils;
|
||||
* @Date 2025/05/05 21:10
|
||||
* @Describe TimeStampRemoteViewsUtil
|
||||
*/
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.widget.RemoteViews;
|
||||
import android.widget.TextView;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import cc.winboll.studio.timestamp.MainActivity;
|
||||
import cc.winboll.studio.timestamp.R;
|
||||
import cc.winboll.studio.timestamp.receivers.ButtonClickReceiver;
|
||||
|
||||
@@ -26,6 +29,7 @@ public class TimeStampRemoteViewsUtil {
|
||||
Context mContext;
|
||||
RemoteViews mRemoteViews;
|
||||
TextView mtvMessage;
|
||||
Notification mNotification;
|
||||
|
||||
TimeStampRemoteViewsUtil(Context context) {
|
||||
mContext = context;
|
||||
@@ -64,10 +68,10 @@ public class TimeStampRemoteViewsUtil {
|
||||
// 这里虽然不能直接设置字体大小,但可以通过反射等方式尝试(不推荐,且有兼容性问题)
|
||||
|
||||
// 创建点击通知后的意图
|
||||
//Intent intent = new Intent(mContext, MainActivity.class);
|
||||
//PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
Intent intent = new Intent(mContext, MainActivity.class);
|
||||
PendingIntent pendingMainIntent = PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
// 设置通知的点击事件
|
||||
//mRemoteViews.setOnClickPendingIntent(R.id.btn_copytimestamp, pendingIntent);
|
||||
mRemoteViews.setOnClickPendingIntent(R.id.tv_timestamp, pendingMainIntent);
|
||||
|
||||
// 创建点击按钮后要发送的广播 Intent
|
||||
Intent broadcastIntent = new Intent(ButtonClickReceiver.BUTTON_COPYTIMESTAMP_ACTION);
|
||||
@@ -91,6 +95,7 @@ public class TimeStampRemoteViewsUtil {
|
||||
|
||||
// 显示通知
|
||||
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