1
我的應用有一個按鈕,該按鈕可導致(應該引導,準確:))到GooglePlay中另一個應用的頁面。按鈕的點擊反應如下:Android:嘗試訪問商店時拋出異常
public void pressedPurchaseButton(View view)
{
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.infmanrb.multrainer"));
startActivity(browserIntent);
}
然而,在仿真器,按鈕按下導致異常:
Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://details?id=com.infmanrb.multrainer }
我猜GOOGLEPLAY是不是在模擬器安裝 - 這就是原因。但無論如何,避免應用程序崩潰的正確方法是什麼?我能否提前檢查意向是否會被處理?或者唯一的方法是嘗試捕捉異常?
確實能起到不安裝在模擬器上。爲了避免崩潰,您可以要求內容解析器簡單地捕獲異常 – njzk2