0

I'm trying to display a notification with a custom view that got a DigitalClock inside. The service crash on start. Here is my code:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <DigitalClock
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/myClock"
        android:textSize="75dp"
        android:layout_alignParentRight="true"
        android:gravity="center_horizontal" />

</LinearLayout>

On my service:

RemoteViews mViews = new RemoteViews(this.getPackageName(), R.layout.clock_layout);

    Notification notification = new Notification();
    notification.when = 0;
    notification.icon = R.drawable.ic_launcher;
    notification.contentView = mViews;

    notification.priority = 500;
    notification.flags = notification.FLAG_ONGOING_EVENT;
    notification.flags = Notification.FLAG_NO_CLEAR;

    startForeground(2366, notification);

Any suggestion?

iGio90
  • 3,251
  • 7
  • 30
  • 43

1 Answers1

0

Solved... apparently the DigitalClock widget can't be inflated on a notification service.

Use TextClock (API 17) instead.

iGio90
  • 3,251
  • 7
  • 30
  • 43