주기적으로 알림 진행 상황을보고하는 다운로드 작업이 있습니다. 잠시 동안 한 번씩 RemoveView 개인 멤버를 사용하여 업데이트했습니다. 예를 들어누군가가 RemoteViews GC 동작을 설명 할 수 있습니까?
:
private RemoteViews mRemoteView;
protected void onCreate(){
mRemoteView = new RemoteViews(getPackageName(), R.layout.custom_layout)
contentView.setImageViewResource(R.id.notification_icon, R.drawable.downloads);
contentView.setTextViewText(R.id.notification_text, "Downloading A File " + (int)((double)progress/(double)max * 100) + "%");
contentView.setProgressBar(R.id.mProgress, max, progress, false);
notification.contentView = contentView;
mNotificationManager.notify(HELLO_ID, notification);
}
protected void onProgressUpdate(Integer... prog) {
contentView.setProgressBar(R.id.mProgress, max, progress, false);
mNotificationManager.notify(HELLO_ID, notification);
}
그러나, 나는 GC가 지속적으로 공간을 취소하고 오랜 시간 동안 크롤 링을 아래로 그 응용 프로그램을 둔화 된 것으로 나타났다. 나는 내가 업데이트 할 때마다 새로운 RemoteView를 생성하려고 노력했다. 왜 이런지 궁금하네요. 나는 종류의 도움이되었다 here를 찾아 냈다, 그러나 나는 정보 더를 찾고있다.
는protected void onProgressUpdate(Integer... prog) {
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_notification_layout);
contentView.setImageViewResource(R.id.notification_icon, R.drawable.downloads);
contentView.setTextViewText(R.id.notification_text, "Downloading A File " + (int)((double)progress/(double)max * 100) + "%");
contentView.setProgressBar(R.id.mProgress, max, progress, false);
notification.contentView = contentView;
mNotificationManager.notify(HELLO_ID, notification);
}
답해 주셔서 감사합니다. 시간이 지나도 대기열이 제거 되나요? 그래서 내 onProgressUpdate()가 1 시간마다 호출되면 (그냥 긴 예제 사용) 문제가 없어야합니다. 내 예제에서는 매우 자주 업데이트되어 큐가 문제가되는 이유를 알 수 있습니다. – Pzanno
예, 사용 속도가 느리면 문제가 덜 심각합니다. GC가 작업에 대처할 수 있습니다. 그러나 이것은 RemoteViews 내의 큐가 지워진다는 사실을 바꾸지 않습니다. RemoteView는 뷰를 빌드하기위한 일련의 명령입니다. 원격 측에서보기를 작성하는 것보다 명령을 계속 추가하는 경우 시간이 오래 걸립니다. –