gpt4 book ai didi

java - 锁屏上的透明对话框可回复 Whatsapp 等消息

转载 作者:太空宇宙 更新时间:2023-11-04 11:42:21 25 4
gpt4 key购买 nike

我正在尝试在 Android 中创建一个锁屏对话框通知,例如 Whatsapp 回复

这是我尝试过的

public void sendNotification(String msg, Intent i, String title)
{
mNotificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);

String replyLabel = "Reply";
RemoteInput remoteInput = new RemoteInput.Builder("KEY_REPLY")
.setLabel(replyLabel)
.build();

PendingIntent contentIntent = PendingIntent.getActivity(context, 100, i,
PendingIntent.FLAG_UPDATE_CURRENT);

NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder(
R.drawable.ic_phone, replyLabel, contentIntent)
.addRemoteInput(remoteInput)
.setAllowGeneratedReplies(true)
.build();

NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher))
.setContentTitle(title)
.setDefaults(Notification.DEFAULT_SOUND)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText("Content Hidden"))
.setContentText(msg)
.addAction(replyAction)
;

mBuilder.setContentIntent(contentIntent);
mNotificationManager.cancel(Constants.PUSH_ID);
mNotificationManager.notify(Constants.PUSH_ID, mBuilder.build());
}



Intent myIntent = new Intent(MainActivity.this, NotificationActivity.class); ApiManager.getInstance().mChatManager.sendNotification("message", myIntent, "Muhammad Umar");

为了使其看起来透明,我尝试过

<style name="Theme.CustomTranslucent" parent="android:style/Theme.Translucent">
<item name="android:backgroundDimEnabled">true</item>
<item name="android:backgroundDimAmount">0.5</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
<item name="android:background">@android:color/transparent</item>
</style>

但是我得到了结果

enter image description here

背景是暗白色的,我无法将其设置为透明。我的做法正确吗?为什么 Activity 不透明。

最佳答案

<style name="AppTheme.NoActionBar.Transparent">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@color/transperent_green</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:backgroundDimEnabled">false</item>
</style>

<color name="transperent_green">#CC07D1C8</color>


<activity
android:name=".YourActivityName"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar.Transparent"></activity>

关于java - 锁屏上的透明对话框可回复 Whatsapp 等消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42663161/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com