相关疑难解决方法(0)

在Android 5 Lollipop中,通知栏图标变为白色

我有一个显示自定义通知的应用.问题是,在Android 5中运行时,通知栏中的小图标显示为白色.我怎样才能解决这个问题?

android android-notifications android-5.0-lollipop

204
推荐指数
9
解决办法
19万
查看次数

调用需要API级别16(当前最小值为14):android.app.Notification.Builder #build

在此输入图像描述文档说在API级别11中添加了Notification.Builder.为什么我会收到此lint错误?

调用需要API级别16(当前最小值为14):android.app.Notification.Builder #build

notification = new Notification.Builder(ctx)
                .setContentTitle("Title").setContentText("Text")
                .setSmallIcon(R.drawable.ic_launcher).build();
Run Code Online (Sandbox Code Playgroud)

表现:

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="17" />
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?

如果我错了,请纠正我但是在11级添加了API,对吗? 在API级别11中添加

android android-lint

33
推荐指数
3
解决办法
3万
查看次数

Jelly Bean中的自定义可扩展通知(4.1)

Jelly Bean添加了对可扩展状态通知的支持.根据http://developer.android.com/about/versions/jelly-bean.html:

除了模板化样式,您还可以使用任何远程视图创建自己的通知样式.

怎么办?我相信你需要创建一个自定义的Notification.Style.这是一个抽象类,所以我需要扩展它.我无法找到有关哪些部分需要扩展的文档.

这个SO问题给出了如何使用notificaiton.builder进行基本通知的一个很好的例子,我将此作为起点.添加

.setContent(new RemoteViews(getPackageName(), R.layout.notification)) 
Run Code Online (Sandbox Code Playgroud)

为基本通知添加自定义视图,但它不可扩展.

android android-notifications android-4.2-jelly-bean

18
推荐指数
2
解决办法
1万
查看次数

如何创建在Android中点击时不会消失的通知?

int icon = R.drawable.icon4;        
CharSequence tickerText = "Hello"; // ticker-text
long when = System.currentTimeMillis();         
Context context = getApplicationContext();     
CharSequence contentTitle = "Hello";  
CharSequence contentText = "Hello";      
Intent notificationIntent = new Intent(this, Example.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
Notification notification = new Notification(icon, tickerText, when);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
Run Code Online (Sandbox Code Playgroud)

这对我不起作用.

我怎么能创建一个可点击的通知并转到我的应用程序,但点击后不会消失?

notifications android

11
推荐指数
2
解决办法
3万
查看次数

如何在通知栏中添加应用程序图标?

我明白这是可能的.至少我看到各种应用程序用于将通知托盘放入其图标(例如Skype).

我的申请怎么样?如何在通知栏中输入我的图标或信息?

notifications android tray

9
推荐指数
1
解决办法
2万
查看次数

android通知大图片无效

我正在创建这样的通知:

        Intent intent = new Intent(this, OfferNotification.class);
        PendingIntent pIntent = PendingIntent.getActivity(this, 0,
                intent, 0);
        Uri soundUri = RingtoneManager
                .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
                this).setSmallIcon(R.drawable.unknown)
                //.setLargeIcon(BitmapFactory.decodeResource( getResources(), R.drawable.unknown))
                .addAction(R.drawable.ic_launcher, "d", pIntent)
                .setAutoCancel(true)
                .setContentTitle("Offer from " + restaurantName)
                .setContentText(offerDescriptoin).setSound(soundUri);
        // Creates an explicit intent for an Activity in your app
        Intent resultIntent = new Intent(this, OfferNotification.class);
        resultIntent.putExtra("offerID", offer.getID());
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);

        stackBuilder.addParentStack(OfferNotification.class);

        stackBuilder.addNextIntent(resultIntent);
        PendingIntent resultPendingIntent = stackBuilder
                .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
        mBuilder.setContentIntent(resultPendingIntent);
        NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        mNotificationManager.notify(offer.getID(), mBuilder.build());
Run Code Online (Sandbox Code Playgroud)

当我使用小图标时,它工作得非常好,但是当我使用大图标时,我可以发出通知的声音,但通知本身不会出现,任何帮助pelase?

android android-notifications

5
推荐指数
1
解决办法
2万
查看次数

每 5 分钟通知一次

我想每 5 分钟向用户发送一次通知,我正在使用以下代码。它第一次向我显示通知,但下次不给。

public void startAlarm() {
    AlarmManager alarmManager = (AlarmManager) this.getSystemService(this.ALARM_SERVICE);
    long whenFirst = System.currentTimeMillis();         // notification time
    Intent intent = new Intent(this, NotifyUser.class);
    PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, 0);
    alarmManager.setRepeating(AlarmManager.RTC, whenFirst, 60*5000, pendingIntent);            
}

public class NotifyUser extends Service {   
    @Override
    public IBinder onBind(Intent intent) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        loadNotification(); 
    }

    private void loadNotification() {
        NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        Notification notify = new Notification(R.drawable.ic_launcher/*android.R.drawable.stat_notify_more*/, "Hanumanji …
Run Code Online (Sandbox Code Playgroud)

android android-alarms

5
推荐指数
2
解决办法
1万
查看次数

Android,Urban AirShip - 改变消息

如何将Android中的通知消息更改为本地化?我只想更改从Urban AirShip获得的信息,然后才能在通知栏上显示?

notifications android urbanairship.com

1
推荐指数
1
解决办法
1917
查看次数

来自服务的持久性android通知

如何进行持久通知,每次用户看到它时都会更新?形成服务

service notifications android persistent

1
推荐指数
1
解决办法
1931
查看次数