在Android中,如果用户具有锁定屏幕并且已选择隐藏敏感信息选项,则在屏幕被锁定时,通知的描述显示为"内容隐藏".我知道这就是该功能的设计方式,但在这种情况下,我的应用程序通知是否也可以显示为正常通知?
我的应用程序完全基于通知,所以我想给用户一个更改,如果他愿意,总是看到通知.我试图寻找一种始终显示通知文本但无法找到任何内容的方法.
notifications android android-notifications android-notification-bar
在 android 通知中,它们的接缝是 3 个不同的图标(见下图)。我知道如何设置大图标(通过setlargeicon),但是我不知道如何设置这两个小图标,因为它们只有一个可用的程序setSmallIcon。
我在这样的通知栏上显示通知.我收到了这些,但我不能在那里显示多个通知,一次只能显示一个.当一个新的到来时,前一个去.问题是什么?
public void createNotificationRecever(Context context, String payload) {
Toast.makeText(context, commentor + "commented on your post " ,Toast.LENGTH_LONG).show();
//New message received
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.flag,
payload, System.currentTimeMillis());
// Hide the notification after its selected
notification.flags |= Notification.FLAG_AUTO_CANCEL;
Intent intent = new Intent(context, MessageReceivedActivity.class);
intent.putExtra("id", groupid);
intent.putExtra("userid", text);
intent.putExtra("cname", groupname);
intent.putExtra("image", "");
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
intent, 0);
notification.setLatestEventInfo(context, "Message",
payload, pendingIntent);
notificationManager.notify(0, notification);
}}
Run Code Online (Sandbox Code Playgroud) android android-notifications android-notification-bar google-cloud-messaging
当我点击通知时,请应用以下内容:
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
在应用程序的所有"startActivity"中,我应用了下一个标志:
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
Run Code Online (Sandbox Code Playgroud)
startActivity我的通知执行以下操作:调用活动"Splash"并称为"Main".
Casulidad如果我在"主"脉冲通知中,关闭电流(正常工作).但是,如果我在活动"新闻"并且通知脉冲,我有2个活动开放,新的"主要"和前"新闻".
如何通过单击通知关闭我的应用程序的任何活动?
notifications android android-notifications android-notification-bar android-activity
我正在开发一款Android应用.我是我的应用程序,我正在尝试向用户显示进程通知.但我想要的是我不希望通知打开一个活动或在被点击时删除.我正在做的是当用户点击按钮时我正在显示通知.通知将说"转移数据".通知从接收方发出.
因此,当用户单击按钮时,将调用接收器.但我不希望在用户单击时删除或关闭该通知.我也不想展示任何活动.我只想在数据处理完成后关闭自己.请参阅下面的方案.
这是我的接收器,单击按钮时显示通知
public class GalleryImageUploadReceiver extends BroadcastReceiver {
private Context context;
private NotificationCompat.Builder notification;
@Override
public void onReceive(Context pContext, Intent intent) {
this.context = pContext;
showProcessNotification();
doAsyncTaskInBackground()
}
public void doAsyncTaskInBackground()
{
//I want to close it here after task is finished
}
public void showProcessNotification()
{
try{
notification = new NotificationCompat.Builder(context);
notification.setAutoCancel(true);
notification.setSmallIcon(R.mipmap.ic_launcher);
notification.setWhen(System.currentTimeMillis());
notification.setTicker("Transferring data...");
notification.setContentTitle(context.getResources().getString(R.string.app_name));
notification.setContentTitle("Transferring data...");
notification.setOngoing(true);
notification.setDefaults(Notification.FLAG_ONGOING_EVENT);
Intent i = new Intent(context.getApplicationContext(), MainActivity.class);//In this line, I do not want to open any activity
i.putExtra("start", …Run Code Online (Sandbox Code Playgroud) notifications android android-notifications android-notification-bar
我有一个应用程序,当用户在应用程序上输入的特定事件发生时生成通知.例如,用户输入了7个事件,而他没有点击通知,然后通知栏将变满.我不希望这样.我想只显示一个通知图标,但只显示所有7个通知.就像whatsapp只显示1个通知图标的地方一样.
我正在努力在 Android 中构建本地通知。我设法在状态栏中显示了一个本地通知,但我无法使用setAutoCancel()或任何方式隐藏它。这是我的代码:
我的用例是:我向用户显示一个本地通知,表明我正在做一些处理。完成处理后,我会更改通知上的文本
NotificationManager manager = NotificationManagerCompat.from( this );
NotificationBuilder builder = new NotificationCompat.Builder( getApplicationContext() );
builder.setOngoing( true )
.setSmallIcon( R.drawable.X )
.setContentTitle("Content title")
.setPriority( NotificationCompat.PRIORITY_MAX )
.setProgress( 100, 0, false );
Notification notification = builder.build();
notification.flags = Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR | Notification.FLAG_FOREGROUND_SERVICE;
manager.notify( 100, notification );
Run Code Online (Sandbox Code Playgroud)
完成一些处理后,我希望能够清除通知,因此我执行以下操作:
PendingIntent btPendingIntent = PendingIntent.getActivity( this, 0, new Intent( ), 0 );
NotificationCompat.Builder mb = new NotificationCompat.Builder(this);
mb.setSmallIcon( R.drawable.ic_action_X )
.setLargeIcon( bitmap )
.setContentTitle("Upload complete")
.setAutoCancel( true );
mb.setContentIntent( btPendingIntent …Run Code Online (Sandbox Code Playgroud) 我正在尝试在触发警报时在通知栏中显示通知.以下是我的代码.
AlarmReciever.java
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.SmsManager;
import android.util.Log;
import android.widget.Toast;
/**
* Created by Yohan on 6/29/2016.
*/
public class AlarmReciever extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
// TODO Auto-generated method stub
// here you can start an activity or service depending on your need
// for ex you can start an activity to vibrate phone or to ring the phone
String message="Hi I will …Run Code Online (Sandbox Code Playgroud) java android android-notifications android-notification-bar android-broadcastreceiver