0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ServiceからDialogを出す

Last updated at Posted at 2019-11-21

方法1:Dialogを使わない、自分はWindowManager.addViewの方法でViewを出す。
方法2:どうしてもカスタマイズDialog(AOSP Dialogを継承)を出す場合、
以下の一行のソースを追加したらできます
Dialog.show()を呼ぶ前に
getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
追加する

2.ServiceでWindowManager.addViewを使う時、以下のエラーが出る。
Can't create handler inside thread that has not called Looper prepare

対応方法:
final Handler handler = new Handler(Looper.getMainLooper());
       handler.post(new Runnable(){
         @Override
         public void run (){
          //ここは実行したいaddviewソース
         }
       });

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?