LoginSignup
7

More than 3 years have passed since last update.

java.lang.RuntimeException: Unable to resume activity

Last updated at Posted at 2014-12-05

java.lang.RuntimeException: Unable to resume activity

というエラーが出た。
しらべてみたら、下記の場合に発生するようだ。

※onCreate以外のイベント(onResumeとか)でAlertDialogを構築する場合,
Builder生成時に getApplicationContext() してしまうと上記のエラーになる。

・・・・しらんがなw
修正方法は下記のようにする。

<修正前>
Toast.makeText(getApplicationContext(), "警告を表示", Toast.LENGTH_LONG).show();
<修正後>
Toast.makeText(this, "警告を表示", Toast.LENGTH_LONG).show();

もう・・・いろいろあるなぁ。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7