通知管理器崩溃android aacplayer应用程序

时间:2012-10-26 22:15:07

标签: android

嗨我有我的应用程序aacplayer在我的galaxy s3中运行良好,但是在android 2.3.4我的应用程序崩溃的星系王牌中但是如果我从代码中删除通知管理器那么它的工作完善。

继承人我的通知经理代码:

public void playerMetadata(final String key, final String value) {
        TextView tv = null;

        if ("StreamTitle".equals(key) || "icy-name".equals(key)
                || "icy-description".equals(key)) {
            tv = txtMetaTitle;
        } else if ("icy-url".equals(key)) {
            tv = txtMetaUrl;
        } else
            return;

        final TextView ftv = tv;

        uiHandler.post(new Runnable() {
            public void run() {
                ftv.setText(value);
                int NOTIFICATION_ID = 1;
                String ns = Context.NOTIFICATION_SERVICE;
                Context context = getApplicationContext();

                NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
                int icon = R.drawable.notificacion;
                long when = System.currentTimeMillis();
                CharSequence tickerText = "Reproduciendo...";
                Notification notification = new Notification(icon, tickerText,
                        when);
                RemoteViews contentView = new RemoteViews(getPackageName(),
                        R.layout.notification);
                contentView.setImageViewResource(R.id.icon, R.drawable.notificacion);
                contentView.setTextViewText(R.id.title_text, txtMetaTitle
                        .getText().toString());

                contentView.setTextViewText(R.id.message_text, txtMetaUrl
                        .getText().toString());

                notification.contentView = contentView;
                Intent notificationIntent = new Intent(AACPlayerActivity.this,
                        Principal.class);

                // Intent notificationIntent = new Intent(this,
                // Principal.class);
                PendingIntent contentIntent = PendingIntent.getActivity(
                        context, 0, notificationIntent, 0);

                // PendingIntent contentIntent = PendingIntent.getActivity(this,
                // 0, notificationIntent, 0);
                notification.contentIntent = contentIntent;
                notification.flags |= Notification.FLAG_ONGOING_EVENT;
                mNotificationManager.notify(NOTIFICATION_ID, notification);
            }
        });
    }

我不知道为什么在星系s3中工作得很好但在星系王牌中没有如何解决这个问题。

非常感谢你。

编辑:

logcat的:

E/AndroidRuntime(16846): android.app.RemoteServiceException: Bad notification posted from package com.spoledge.aacplayer: Couldn't expand RemoteViews for: StatusBarNotification(package=com.spoledge.aacplayer id=1 tag=null notification=Notification(vibrate=null,sound=null,defaults=0x0,flags=0x2))

如果我在我的代码中添加它:

notification.setLatestEventInfo(context, 
txtMetaTitle.getText().toString(), 
txtMetaUrl.getText().toString(), contentIntent);

通知工作没有问题,但我需要用以下方式显示通知:

contentView.setTextViewText(R.id.title_text, txtMetaTitle
                        .getText().toString());

                contentView.setTextViewText(R.id.message_text, txtMetaUrl
                        .getText().toString());

txtmetatitle字段有一个选取框,但如果在notification.setLatestEvent之前添加该行,则可以正常工作但不能使选框正确运行

0 个答案:

没有答案