我有一個奇怪的錯誤與Android LiveWallpaper趕上嘗試最後。當我設置這個 它適用於API的周圍2.3ish:奇怪的抓住嘗試最後錯誤
Canvas canvas = null;
//Keep trying till wallpaper is set.
//Error around here..
try
{
canvas = this._surfaceHolder.lockCanvas(null);
synchronized (this._surfaceHolder)
{
this.onDraw(canvas);
}
}
finally
{
if(canvas != null)
{
this._surfaceHolder.unlockCanvasAndPost(canvas);
}
}
這一點也適用於ICS &蜂窩(在真實設備上測試)
Canvas canvas = null;
//Keep trying till wallpaper is set.
//Error around here..
try
{
canvas = this._surfaceHolder.lockCanvas(null);
synchronized (this._surfaceHolder)
{
this.onDraw(canvas);
}
}
finally
{
if(canvas != null)
{
this._surfaceHolder.unlockCanvasAndPost(canvas);
}
}
當livewallpaper的「設置」時出現錯誤。 (服務失敗,「異常鎖定服務」) 我如何從一個編譯中得到它的工作?我不想要兩個不同的版本。
我無法找到差異 – weston 2012-02-14 11:50:06
這裏沒有真正的問題。你有什麼錯誤?而且,因爲我要麼失明,要麼瘋狂,這兩個代碼片段之間有什麼區別 - 它們看起來與我相同? – 2012-02-14 11:51:26
@weston說了些什麼,再加上 - 如果你正在使用嘗試,最後,你不應該捕捉什麼?您的應用程序崩潰,因爲您沒有捕獲正在拋出的異常。 – RivieraKid 2012-02-14 11:52:52