1
私のアプリケーションでは、ハードウェアボリュームキーを押すと現在のボリュームでトーストが表示されるように実装しました。物事はほとんどの時間よく行く。しかし、ボリュームキーを長押しすると、アプリケーションがクラッシュすることがあります。私はトーストオブジェクトを持っており、すべてのキープレスイベントのために、私は、ビューを膨らま内のビューの要素を設定し、トーストに設定し、検出 :トーストクラッシュアプリケーション
....
11-19 06:43:22.114 I/NotificationService(2783): enqueueToast pkg=com.FunTime.android callback=android.app.ITransientNotification[email protected] duration=0
11-19 06:43:22.119 V/WindowManager(2783): Delivering key 25 to Window{47f6a930 com.FunTime.android/com.FunTime.android.map.MapActivity paused=false}
11-19 06:43:22.164 I/NotificationService(2783): enqueueToast pkg=com.FunTime.android [email protected] duration=0
11-19 06:43:22.169 V/WindowManager(2783): Delivering key 25 to Window{47f6a930 com.FunTime.android/com.FunTime.android.map.MapActivity paused=false}
11-19 06:43:22.209 I/NotificationService(2783): enqueueToast pkg=com.FunTime.android [email protected] duration=0
...many such notifications...
11-19 06:43:22.244 E/SurfaceFlinger(2783): createSurface() failed, generateId = -12
11-19 06:43:22.244 W/WindowManager(2783): OutOfResourcesException creating surface
11-19 06:43:22.244 I/WindowManager(2783): Out of memory for surface! Looking for leaks...
11-19 06:43:22.244 W/WindowManager(2783): No leaked surfaces; killing applicatons!
11-19 06:43:22.244 W/ActivityManager(2783): Killing processes for memory at adjustment 0
11-19 06:43:22.244 W/ActivityManager(2783): Killing for memory: ProcessRecord{47dd75c8 3246:com.FunTime.android/10079} (adj 0)
11-19 06:43:22.244 I/Process (2783): Sending signal. PID: 3246 SIG: 9
11-19 06:43:22.244 W/WindowManager(2783): Looks like we have reclaimed some memory, clearing surface for retry.
11-19 06:43:22.244 W/WindowManager(2783): Due to memory failure, waiting a bit for next layout
私は従うアプローチ:ログには、次のされてクラッシュに発生しましたトーストを表示します。
何が問題になりますか?あなたはあまりにも多くの乾杯を行い、メモリがいっぱいにmyAudioManager
public void showVolumeAdjustment(final int adjustment)
{
volumeToast.setDuration(Toast.LENGTH_SHORT);
volumeToast.setView(getVolumeProgressBarView(adjustment));
volumeToast.setGravity(Gravity.TOP,0,0);
volumeToast.show();
}
private View getVolumeProgressBarView(int adjustment)
{
LayoutInflater inflater = (LayoutInflater) myApplication.getInstance().getApplicationContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
toastView= inflater.inflate(R.layout.volume_toast, null);
ProgressBar pb =(ProgressBar)toastView.findViewById(R.id.level);
pb.setMax(MAX_VOICE_VOLUME_ENGINE);
pb.setProgress(adjustment);
return toastView;
}
キープレスイベントハンドラの設定方法とトーストの表示方法を示すコードを投稿する必要があります。あなたが実際に行っていることを見て間違っていることを言うのは難しいです。 – Nailuj