嗨,我在我的应用程序中有我的自定义通知,在android 2.2 2.3 4.0中工作完美,但在我尝试过的4.1.1果冻豆中不能完美运行,但是我无法在我的自定义通知中使用选取框,这是我的代码.xml:

<TextView
                    android:id="@+id/notification_title"
        style="@style/NotificationTitle"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:ellipsize="marquee"
            android:fadingEdge="horizontal"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:gravity="bottom"
            android:marqueeRepeatLimit="marquee_forever"
            android:scrollHorizontally="false"
            android:singleLine="true"
            android:textSize="20sp"
            android:textStyle="bold" >

            <requestFocus />
        </TextView>

        <TextView
                   android:id="@+id/notification_text"
        style="@style/NotificationText"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/notification_title"
            android:layout_marginTop="3dp"
            android:textSize="15sp" >
        </TextView>


我的通知代码:

            int NOTIFICATION_ID = 1;
            String ns = Context.NOTIFICATION_SERVICE;
            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.setTextViewText(R.id.notification_title, txtMetaTitle.getText().toString());
            contentView.setTextViewText(R.id.notification_text, txtMetaUrl.getText().toString());
            notification.contentView = contentView;
            Intent notificationIntent = new Intent(AACPlayerActivity.this, Principal.class);
            PendingIntent contentIntent = PendingIntent.getActivity(AACPlayerActivity.this, 0, notificationIntent, 0);
            notification.contentIntent = contentIntent;
            notification.flags |= Notification.FLAG_ONGOING_EVENT;
            mNotificationManager.notify(NOTIFICATION_ID, notification);
        }


我的应用程序运行良好,但是字幕无法启动不知道为什么在4.1.1中?我该怎么解决这个问题?

非常感谢你。

最佳答案

请注意:不建议在Notification中构建通知,而推荐使用Builder子类。另外,要获得跨平台的兼容性,您应该考虑使用android.support.v4.app.NotificationCompat。您应该能够使用相同的RemoteViews;尝试切换到新方法,看看会发生什么。

09-10 02:21
查看更多