0

Is there a way to display some sort of warning view across all of my app when the user does not have internet access? Maybe even have a way for the user to enable wifi or a mobile data connection from that warning view / dialog?

I'm trying to avoid having to copy paste some sort of dialog warning to every activity in my app.

Kaushik NP
  • 6,733
  • 9
  • 31
  • 60
Dportology
  • 836
  • 1
  • 9
  • 32
  • 1
    I think you can use a BaseActivity and do what you want(display some sort of warning view) in it, and all your activity extends it. not only fit for this situation, the BaseActivity is also used for other duplicated code. – EricHua23 Feb 21 '17 at 02:30
  • 1
    look this. It may help. http://stackoverflow.com/a/37707741/5241603 – K.Sopheak Feb 21 '17 at 03:00

1 Answers1

1

Build the logic to display and hide the warning into a Fragment, and just include the fragment in each Activity. No copy paste needed (or at least, just 1 line in each activity's main xml file).

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127