在磨损设备上,我看到每个应用只能显示12个通知。例如,当我收到大约20封新电子邮件时,该应用程序仅显示最近的12封电子邮件,而不是更多。
同样,我写了一个磨损应用程序,它会抛出通知,即使它没有显示超过12个通知,任何新通知在此之后排队,并且不会在通知中显示,直到现有的已被清除。因此,在任何给定的点上,最多只能显示12个通知。
google是否有磨损限制?
这是我的代码..
PhoneDataListener,它从移动应用程序接收dataItem ..
public class PhoneDataListenerService extends WearableListenerService {
private static final String TAG = "Listener-W";
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
for (DataEvent event : dataEvents) {
Log.v(TAG, "DataMap received on watch: " + DataMapItem.fromDataItem(event.getDataItem()).getDataMap());
// Check the data type
if (event.getType() == DataEvent.TYPE_CHANGED) {
// Check the data path
String path = event.getDataItem().getUri().getPath();
if (path.equals("/weardatapath")) {}
DataMapItem dataMapItem = DataMapItem.fromDataItem(event.getDataItem());
ArrayList<DataMap> dataItemsList = dataMapItem.getDataMap().getDataMapArrayList
("dataMapItems");
// Broadcast DataMap contents to wearable show in notification..
if (dataItemsList != null && dataItemsList.size() > 0) {
// start service for each Item in the dataItemsList
for (DataMap dMapItem : dataItemsList) {
startNotificatioService(this, dMapItem);
}
}
}
}
}
public static void startNotificatioService(Context context, DataMap dataMap) {
Log.w(TAG, "start Service to show notification...");
Intent intent = new Intent(context, NotificationService.class);
intent.setAction(NotificationService.ACTION_NOTIFICATION);
intent.putExtra(NotificationService.DATA_PARAM, dataMap.toBundle());
context.startService(intent);
}
}
构建并抛出通知的Wear应用程序上的NotificationService
public class NotificationService extends IntentService {
private final static String TAG = "NotificationService-W";
public static final String ACTION_NOTIFICATION = "com.test.phonewearsample.action.NOTIFIY";
public static final String DATA_PARAM = "dataMap";
private final static String MY_GROUP_KEY = "myGroupKey";
public NotificationService() {
super("NotificationService");
}
@Override
protected void onHandleIntent(Intent intent) {
if (intent != null) {
final String action = intent.getAction();
if (ACTION_NOTIFICATION.equals(action)) {
final Bundle data = intent.getBundleExtra(DATA_PARAM);
handleActionNotification(data);
}
}
}
private void handleActionNotification(Bundle data) {
// Display received data in UI
int dataId = data.getInt(SharedConstants.EXTRA_MAIL_ID);
Log.w(TAG, "###########DataItems############# :"+dataId);
String name = data.getString(SharedConstants.WearMails.CONTACT_NAME);
String number = data.getString(SharedConstants.WearMails.PHONE_NUMBER);
String duration = data.getString(SharedConstants.WearMails.DURATION);
Long uniqueVal = data.getLong(SharedConstants.EXTRA_UNIQUE_ID);
NotificationCompat.BigTextStyle style = new NotificationCompat.BigTextStyle();
style.bigText(number + "\n" + duration);
NotificationCompat.Builder notification = new NotificationCompat.Builder(this)
.setStyle(style)
.setContentTitle(name)
.setSmallIcon(R.mipmap.ic_launcher)
.addAction(R.mipmap.ic_launcher, "Play On Phone",
NotificationUtil.getReplyPendingIntent(this, Integer.toString(dataId)))
.setGroup(MY_GROUP_KEY)
.setVibrate(new long[]{0, 100, 50, 100})
.setSortKey(Long.toString(uniqueVal));
NotificationManagerCompat.from(this).notify(dataId, notification.build());
}
}
请注意,它一次只能显示12个群组通知。一旦我采取行动并且通知被清除,待处理的通知就会进入。
答案 0 :(得分:0)
阅读此内容,我认为这是Google目前正在开发的Android Wear设备的缺陷。您可以在此处查看以下链接:https://code.google.com/p/android/issues/detail?id=130689。我认为这个问题是可穿戴的。