我想创建一个自定义通知直接从通知回复短信是这样的:创建自定义通知,包括编辑文本的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
为什么?我应该怎么做才能做出定制通知? –