android 带有搜索栏的通知

android notification with seekbar

想用图像和搜索栏填充我的通知..... 我的通知功能如下...

public void showNotification(){

    // define sound URI, the sound to be played when there's a notification
            //Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

    int icon = R.drawable.ic_launcher;
    long when = System.currentTimeMillis();
    Notification notification = new Notification(icon, "Custom Notification", when);

    NotificationManager mNotificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);

    Intent notificationIntent = new Intent(this, NotificationReceiver.class);
    PendingIntent pIntent = PendingIntent.getActivity(MainActivity.this, 0, notificationIntent, 0);
   // notification.contentIntent = contentIntent;


    Intent notificationIntent2 = new Intent(this, NotificationReceiver2.class);
    PendingIntent pIntent2 = PendingIntent.getActivity(MainActivity.this, 0, notificationIntent2, 0);
   // notification.contentIntent = contentIntent2;

    RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.result);
    contentView.setImageViewResource(R.id.image, R.drawable.ninja);
    contentView.setImageViewResource(R.id.image2, R.drawable.ninja);

    contentView.setOnClickPendingIntent(R.id.image, pIntent);
    contentView.setOnClickPendingIntent(R.id.image, pIntent2);
   // contentView.setTextViewText(R.id.title, "Custom notification");
  //  contentView.setTextViewText(R.id.text, "This is a custom layout");
    notification.contentView = contentView;



    notification.flags |= Notification.FLAG_NO_CLEAR; //Do not clear the notification
    notification.defaults |= Notification.DEFAULT_LIGHTS; // LED
    notification.defaults |= Notification.DEFAULT_VIBRATE; //Vibration
    notification.defaults |= Notification.DEFAULT_SOUND; // Sound

    mNotificationManager.notify(0, notification);
}

我想在通知中膨胀的布局如下

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

   <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

    </LinearLayout>

    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <SeekBar
        android:id="@+id/seekBar1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    </LinearLayout>
    </LinearLayout>

但是当我想显示异常通知时

01-08 12:33:25.393: E/AndroidRuntime(24069): FATAL EXCEPTION: main
01-08 12:33:25.393: E/AndroidRuntime(24069): android.app.RemoteServiceException: Bad     notification posted from package com.example.androidnotificationbar: Couldn't expand RemoteViews for: StatusBarNotification(pkg=com.example.androidnotificationbar id=0 tag=null score=0 notn=Notification(pri=0 contentView=com.example.androidnotificationbar/0x7f030001 vibrate=default sound=default defaults=0x7 flags=0x20 kind=[null]) tickerText=Custom Notification contactCharSeq=null when=1420700605072 threadId=0)
01-08 12:33:25.393: E/AndroidRuntime(24069):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1407)
01-08 12:33:25.393: E/AndroidRuntime(24069):    at android.os.Handler.dispatchMessage(Handler.java:99)
01-08 12:33:25.393: E/AndroidRuntime(24069):    at android.os.Looper.loop(Looper.java:174)
01-08 12:33:25.393: E/AndroidRuntime(24069):    at android.app.ActivityThread.main(ActivityThread.java:4952)
01-08 12:33:25.393: E/AndroidRuntime(24069):    at java.lang.reflect.Method.invokeNative(Native Method)
01-08 12:33:25.393: E/AndroidRuntime(24069):    at java.lang.reflect.Method.invoke(Method.java:511)
01-08 12:33:25.393: E/AndroidRuntime(24069):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
01-08 12:33:25.393: E/AndroidRuntime(24069):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
01-08 12:33:25.393: E/AndroidRuntime(24069):    at dalvik.system.NativeStart.main(Native Method)

请给我一些建议

据我所知,RemoteViews 不支持SeekBar,您无法实现自己的远程视图。由于默认的通知手势,通知中的搜索栏根本不是一个好主意。您可以使用 https://github.com/pingpongboss/StandOut 的任何方式来实现您需要的浮动通知之类的东西。