远程通知显示空白

时间:2015-10-06 12:34:50

标签: android android-notifications android-remoteview

当我在没有远程查看的情况下创建通知时,它工作正常,但是当我尝试使用远程视图时,通知会显示一个空白屏幕。 这是我的通知代码: - /

RemoteViews remoteViews = new RemoteViews(getPackageName(),
           R.layout.widget);
    remoteViews.setTextViewText(R.id.date,result);
    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
         this).setSmallIcon(R.drawable.common_signin_btn_icon_dark).setContent(remoteViews);

    Intent resultIntent = new Intent(this, NotificationDatabase.class);
    PendingIntent resultPendingIntent =
            PendingIntent.getActivity(
                    this,
                    0,
                    resultIntent,
                    PendingIntent.FLAG_UPDATE_CURRENT
            );
    mBuilder.setContentIntent(resultPendingIntent);
    NotificationManager mNotificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    // mId allows you to update the notification later on.
    mNotificationManager.notify(1, mBuilder.build());

这是我的widget.xml: - /

 <?xml version="1.0" encoding="utf-8"?>
  <RelativeLayout     xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/request"
    android:text="NEW APPOINTMENT REQUEST"
    android:textSize="27dp"
    android:layout_marginTop="81dp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true" />


<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Accept"
    android:id="@+id/accept"
    android:layout_marginLeft="15dp"
    android:layout_below="@+id/request"
    android:layout_alignParentStart="true"
    android:layout_marginTop="61dp" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="DENY"
    android:id="@+id/deny"
    android:layout_marginLeft="20dp"
    android:layout_toRightOf="@+id/accept"
    android:layout_alignTop="@+id/accept"/>

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="CHECK SCHEDULE"
    android:id="@+id/schedule"
    android:layout_alignTop="@+id/accept"
    android:layout_toRightOf="@+id/deny"
    android:layout_marginLeft="20dp" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="OCT 12,12:10 PM, MON"
    android:layout_marginTop="10dp"
    android:textSize="23dp"
    android:id="@+id/date"
    android:layout_below="@+id/request"
    android:layout_alignStart="@+id/request" /></RelativeLayout>

0 个答案:

没有答案