0
显然粘贴的代码(1)将我的服务设置为前台服务,并(2)将我的图标显示在屏幕顶部的托盘上。如果用户点击我的图标,今天的日期很快就会变得模糊 - 我想这是某种默认行为。 ContentTitle和ContentText从不显示(所以它们有什么好处?)允许用户取消前台服务
我想要发生的情况是,当图标被点击下拉或某种类型的popwindow时,显示允许用户选择取消或结束我的服务。我似乎无法找到这样的功能的任何例子。这可以做到吗?怎么样?
顺便说一句,我的通知的唯一目的是让我的服务在前台运行。我从来不需要通知用户任何事情。
谢谢,加里
NotificationCompat.Builder b = new NotificationCompat.Builder(this);
b.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("PhoneStalker")
.setContentText("Hello World");
意图WhatIsThisIntentFor =新意图(Intent.ACTION_VIEW);
b.setContentIntent(PendingIntent.getActivity(this, 0, WhatIsThisIntentFor, 0));
通知n = b.build();
startForeground(5481,n);