당신은 하나 둘 개 선택이 있습니다
해킹 장치가 System.Android.Notification.pas/System.Notification.pas는 당신이 필요로하는 기능을 추가 할 수 있습니다. 그것은 쉽게, 하나의 기능을 업데이트해야하는이 하나
function TNotificationCenterAndroid.CreateNativeNotification(const ANotification: TNotification): JNotification;
function GetDefaultNotificationSound: Jnet_Uri;
begin
Result := TJRingtoneManager.JavaClass.getDefaultUri(TJRingtoneManager.JavaClass.TYPE_NOTIFICATION);
end;
function GetDefaultIconID: Integer;
begin
Result := TAndroidHelper.Context.getApplicationInfo.icon;
end;
function GetDefaultIcon: JBitmap;
begin
Result := TJBitmapFactory.JavaClass.decodeResource(TAndroidHelper.Context.getResources(), GetDefaultIconID);
end;
function GetContentTitle: JCharSequence;
begin
if ANotification.Title.IsEmpty then
Result := StrToJCharSequence(TAndroidHelper.ApplicationTitle)
else
Result := StrToJCharSequence(ANotification.Title);
end;
function GetContentText: JCharSequence;
begin
Result := StrToJCharSequence(ANotification.AlertBody);
end;
function GetContentIntent: JPendingIntent;
var
Intent: JIntent;
begin
Intent := TAndroidHelper.Context.getPackageManager().getLaunchIntentForPackage(TAndroidHelper.Context.getPackageName());
Intent.setFlags(TJIntent.JavaClass.FLAG_ACTIVITY_SINGLE_TOP or TJIntent.JavaClass.FLAG_ACTIVITY_CLEAR_TOP);
SaveNotificationIntoIntent(Intent, ANotification);
Result := TJPendingIntent.JavaClass.getActivity(TAndroidHelper.Context, TGeneratorUniqueID.GenerateID, Intent, TJPendingIntent.JavaClass.FLAG_UPDATE_CURRENT);
end;
var
NotificationBuilder: JNotificationCompat_Builder;
begin
NotificationBuilder := TJNotificationCompat_Builder.JavaClass.init(TAndroidHelper.Context);
NotificationBuilder := NotificationBuilder.setDefaults(TJNotification.JavaClass.DEFAULT_LIGHTS);
if ANotification.SmallIconId <> 0 then NotificationBuilder := NotificationBuilder.setSmallIcon(ANotification.SmallIconId)
else NotificationBuilder := NotificationBuilder.setSmallIcon(GetDefaultIconID);
if ANotification.largeIconObj <> nil then NotificationBuilder := NotificationBuilder.setLargeIcon(ANotification.largeIconObj);
NotificationBuilder := NotificationBuilder.setContentTitle(GetContentTitle);
NotificationBuilder := NotificationBuilder.setContentText(GetContentText);
NotificationBuilder := NotificationBuilder.setTicker(GetContentText);
NotificationBuilder := NotificationBuilder.setContentIntent(GetContentIntent);
NotificationBuilder := NotificationBuilder.setNumber(ANotification.Number);
NotificationBuilder := NotificationBuilder.setAutoCancel(True);
NotificationBuilder := NotificationBuilder.setWhen(TJDate.Create.getTime);
if (ANotification.Color <> TalphaColorRec.null) and
(TJBuild_VERSION.JavaClass.SDK_INT >= 21) then NotificationBuilder := NotificationBuilder.setColor(ANotification.Color);
if ANotification.VibratePattern <> nil then NotificationBuilder := NotificationBuilder.setVibrate(ANotification.VibratePattern);
if ANotification.EnableSound then
if ANotification.SoundName.IsEmpty then
NotificationBuilder := NotificationBuilder.setSound(GetDefaultNotificationSound)
else
NotificationBuilder := NotificationBuilder.setSound(StrToJURI(ANotification.SoundName));
// Action buttons won't appear on platforms prior to Android 4.1!!!
// http://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#addAction
Result := NotificationBuilder.Build;
end;
또는 두 번째 변형, 델파이 TnotificationCenter의 사용을 피하고 처음부터 자신 만의 팁을위한
감사를 구축! BigTextStyle이 정의되지 않았기 때문에 해킹은 그렇게 단순하지 않은 것 같습니다. 이것은 내 첫 모바일 앱이므로 구현 방법을 알아야합니다. – WarmBooter