###前提・実現したいこと
androidでアプリ開発しています。そこにforegraundのサービスを起動し他アプリなどでホームボタンを押したときにdialogFragmentを使用してホーム画面などでダイアログを表示しています。
そのとき、サービス開始したてではすぐにdialogが生成されません。
foregroundがいけないんでしょうか?それともandroidの仕様かなにかでしょうか?
ホームボタン検知以降はこちらのサイトを参考に作りました
https://dev.classmethod.jp/smartphone/android/android-tips-home-alert-dialog/
###該当のソースコード
public void onCreate() { super.onCreate(); final SharedPreferences sn=getSharedPreferences("today",MODE_MULTI_PROCESS); final SharedPreferences.Editor editor=sn.edit(); editor.putInt("start",1).commit(); m_HomeButtonReceive = new HomeButtonReceive(); IntentFilter iFilter = new IntentFilter(); iFilter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); this.registerReceiver(m_HomeButtonReceive, iFilter); } public class HomeButtonReceive extends BroadcastReceiver { @Override public void onReceive(Context arg0, Intent arg1) { final SharedPreferences sn=arg0.getSharedPreferences("today",MODE_MULTI_PROCESS); final SharedPreferences.Editor editor=sn.edit(); if(sn.getInt("end",0)!=1) startService(new Intent(getApplicationContext(), APPintentservice.class)); } }

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/01/28 10:46