我想創建一個自定義通知直接從通知回覆短信是這樣的:創建自定義通知,包括編輯文本的Android
正如我所理解的正常通知必須64dp高度,但你可以用較大的一個從API> 16作爲可擴展的通知,但我認爲64dp高度適合我的情況。我用這個代碼,但它崩潰時,我的自定義通知佈局有編輯短信:
RemoteViews remoteViews = new RemoteViews(getPackageName(),R.layout.widget);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setSmallIcon(R.mipmap.ic_launcher)
.setContent(remoteViews);
Intent resultIntent = new Intent(context, MainActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addParentStack(MainActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(100, mBuilder.build());
錯誤:
android.app.RemoteServiceException: Bad notification posted from package com.example.x: Couldn't expand RemoteViews for: StatusBarNotification
我應該怎麼辦?
「創建包含編輯文本android的自定義通知」 - 您無法在「RemoteViews」中放置「EditText」。 – CommonsWare
爲什麼?我應該怎麼做才能做出定製通知? –