我正在创建像计时器应用程序,当我启动计时器时,我可以选择去Android主页或启动任何其他活动.
当我启动计时器时,我设置了一个通知栏图标,如果我使用其他一些应用程序(意思是从启动计时器活动开始),现在我需要通过点击通知图标来回到我之前启动的计时器活动?
当我点击时,我开始一个新的实例计时器活动,而不是之前启动的计时器活动!,如果我然后单击后退按钮,它会显示我之前的计时器活动..
问题是:如何通过通知栏调用以前启动的活动,而不是启动该活动的新实例?
这是我的代码示例如下:
private void notificationBar()
{
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
int icon = R.drawable.ico;
CharSequence tickerText = "some title...";
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
Context context = getApplicationContext();
CharSequence contentTitle = "some app title";
CharSequence contentText = "...some info !";
Intent notificationIntent = new Intent(this, main.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT | Notification.FLAG_AUTO_CANCEL);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
mNotificationManager.notify(NOTIF_ID, notification);
}
private void notificationClose(int notifID) …Run Code Online (Sandbox Code Playgroud) android android-intent android-notification-bar android-activity
我有一个使用LinearLayout包含a ImageView和a 的自定义通知TextView.在Android 4.0之前,我需要做的就是将文本颜色换成EventContent和EventContent.Title样式,所有颜色看起来都很棒.
但是在Android 4.0(冰淇淋三明治)上,我的自定义通知背景颜色是浅灰色,更糟糕的是它与默认文本样式发生了可怕的冲突.这对我来说很奇怪,因为所有其他通知都有深灰色(几乎是黑色),我在布局中根本没有改变背景颜色.
有没有办法访问通知的默认背景颜色?我不想手动将其设置为黑色(或其他颜色),因为我希望它与设备上的主题配合得很好.但我环顾四周,找不到能给我这种颜色的东西.
notifications android android-notifications android-notification-bar
我知道添加android:theme="@android:style/Theme.NoTitleBar"到清单会删除标题,但是我该怎么做才能删除通知栏?
CustomPushNotificationBuilder如果您想对状态栏通知进行任何修改,Urban Airship建议您创建自定义通知,包括轻松更改图标.
不幸的是,使用RemoteViewfor通知会带来许多与自定义制造商和/或平台特定皮肤相关的不必要的含义,包括文本颜色和对私有资源的引用(例如@*android:drawable/notify_panel_notification_icon_bg_tile在Honeycomb/ICS上).
必须有一种简单的方法来交换图标而不使用RemoteView.怎么样?
android urbanairship.com android-notifications android-notification-bar
我已经实现了一个BigTextStyle/InboxStyle通知,但它显示为正常的通知,它显示在我的HTC One X AT&T(4.1.1)上的JellyBean(在Gingerbread,ICS等中)之前.甚至动作按钮也未显示.
我用模拟器检查我的代码(使用JellyBean 4.2),这是有效的.
看起来我的HTC One X版本没有实现JellyBean的新Notification System.
HTC One X AT&T设备信息
Android Version - 4.1.1
HTC Sense Version - 4+
Software number - 3.18.502.6 710RD
HTC SDK API Level - 4.63
HTC Extension version - HTCExtension_Sesnse45_2
Run Code Online (Sandbox Code Playgroud)
源代码
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void showNotificationJB(Reminder reminder, Intent intent) {
Log.v(TAG, "Showing BigText Notification");
Notification.Builder builder = new Notification.Builder(this);
builder.setContentTitle("Ezeetrak Scheduler");
AdditionalDataStore store = reminder.getStore();
String passedBy = store.optString("passedBy");
builder.setContentText("Recieved an Event by " + passedBy);
builder.setTicker("Recieved an Event by " + …Run Code Online (Sandbox Code Playgroud) 如何保留操作/标题栏但隐藏通知栏?
这个问题看起来已经得到了回答,但我找到的大部分答案都隐藏了操作栏和通知栏.我希望能够保留动作/标题栏.我得到的最好的是隐藏它们并使用线性布局来显示自定义动作/标题栏但我想要一个系统生成的.还可以在显示通知栏时隐藏操作栏吗?
如何在Android应用程序中添加通知计数器,类似于Facebook的通知计数器?我尝试过搜索,但我找不到任何有用的东西.我不想在发射器图标上使用反气球.相反,我希望它在我的应用程序中的通知图标和朋友图标.
我的搜索包括:
包括这些在内的所有其他示例都在启动器图标上显示通知气球.我不希望通知气球通过启动器图标.相反,我希望我的应用程序中的通知气球覆盖类似于Facebook的通知图标.我该如何实现它?任何建议,步骤或指南将不胜感激.

是否可以在扩展通知中获取文本statusbar?这意味着文字设置了我Notification.BitTextStyle.bigText(),例如来自Gmail的电子邮件通知.
我想使用Notification.extras来获取它,但似乎没有常量,Notification.EXTRA_BIG_TEXT例如,允许它工作.
是否有另一种获取此文本的方法?当我使用时
String bigTitle = mExtras.getString(Notification.EXTRA_TITLE_BIG;
它回来了null,任何想法为什么?我用它来获取电子邮件的主题(Testing the new Gmail notification shortcuts- >见下面的链接).
以下是扩展Gmail通知的示例:(我想获得以下文字 - >
您现在可以获得回复和存档的快捷按钮...
Gmail通知的图片 (无法发布信誉低于10的图片,抱歉)
作为替代方案,我也尝试了以下方法:
RemoteViews rv = mNotification.contentView;
LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ViewGroup localView = (ViewGroup) inflater.inflate(rv.getLayoutId(), null);
rv.reapply(getApplicationContext(), localView);
everything = new StringBuilder(150);
for(int i=0; i<((ViewGroup)localView).getChildCount(); ++i) {
View nextChild = ((ViewGroup)localView).getChildAt(i);
try{
TextView tv = (TextView) localView.findViewById(nextChild.getId());
everything.append(tv.getText().toString());
}catch(Exception e){
continue;
}
}
Log.i("abc", everything.toString());
Run Code Online (Sandbox Code Playgroud)
但这对我来说也不起作用,似乎从来没有从任何观点中得到任何文本.
更新:
当我使用以下代码从通知中获取文本时...:
body = mExtras.getString(Notification.EXTRA_TEXT); …Run Code Online (Sandbox Code Playgroud) notifications android android-notifications android-notification-bar
我发送不同的通知.但是当你点击其中任何一个时,我都会得到已经发送到最后一个通知的数据.怎么解决?我需要注意每个商店的数据,并且新的通知不会取代PendingIntent.FLAG_UPDATE_CURRENT它们.我使用了一个标志, 但我也使用了左边所有的标志.
private void generateNotification(Context context, String title, String message,int groupid,Intent data) {
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
Intent intent = new Intent(context,MyActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
if (groupid==1){
intent.putExtra("guest",data.getStringExtra("guest"));
intent.putExtra("hotel",data.getStringExtra("hotel"));
intent.putExtra("room",data.getStringExtra("room"));
}
if (groupid==5){
intent.putExtra("hotel",data.getStringExtra("hotel"));
}
if (groupid==4){
intent.putExtra("hotel",data.getStringExtra("hotel"));
intent.putExtra("guest",data.getStringExtra("guest"));
}
intent.putExtra("group_id",groupid);
Log.d("mylogout","group_id: "+groupid);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification = new NotificationCompat.Builder(context)
.setContentIntent(pendingIntent)
.setSmallIcon(R.drawable.ic_stat_gcm)
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_stat_gcm))
.setTicker("????? ?????????")
.setWhen(System.currentTimeMillis())
.setAutoCancel(true)
.setContentTitle(title)
.setContentText(message)
.build();
notificationManager.notify(ID_NITIF++, notification);
}
Run Code Online (Sandbox Code Playgroud) android android-intent android-notifications android-notification-bar
我正在以下面给出的方式构建服务中的通知进度条:
private NotificationManager mNotifyManager;
private NotificationCompat.Builder mBuilder;
mBuilder =
new NotificationCompat.Builder(DownloadService.this)
.setSmallIcon(R.drawable.download)
.setContentTitle("MayUp")
.setContentText("Downloading new tools")
.setTicker("Downloading in progress");
mBuilder.setAutoCancel(true);
Intent targetIntent = new Intent(DownloadService.this, ListClass.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(DownloadService.this);
// Adds the back stack for the Intent (but not the Intent itself)
stackBuilder.addParentStack(MyActivity.class);
// Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(targetIntent);
// PendingIntent contentIntent = PendingIntent.getActivity(DownloadService.this, 0, targetIntent, PendingIntent.FLAG_UPDATE_CURRENT);
// mBuilder.setContentIntent(contentIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,
PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);
mNotifyManager.notify(1, mBuilder.build());
mBuilder.setProgress(100, 0, false); …Run Code Online (Sandbox Code Playgroud) android android-progressbar android-notifications android-notification-bar
android ×10