开发者

Want to add a startup notification Droid app

I am looking to add a Notification whe开发者_StackOverflow社区n the app is started. That will ask the user if they have a WiFi or unlimited connection. If they pick yes then they can go into the app, if no then the app closes with a message 'Try again later...'


To find out if wifi is available, you don't need to ask the user, you can ask the OS to give you that information using this method:

http://developer.android.com/reference/android/net/NetworkInfo.html#getTypeName%28%29

If you wish, you can also check if there is a connection using isConnected() and if you want to test if the connection is working, you could make a network call to confirm.

If you want to have the user confirm (I don't think you need to) then create an activity that runs when the app starts, it asks them to confirm, and then depending on their selection either starts the app's main activity, or shows a message and exits.

I don't know the details of your app, but if it were me I would probably: - Automate the network detection - If there's no network, run the app as usual, but just grey out and disable the main UI, and show a message like "Please connect to a Wifi network". - Consider including a user interface within the app that the user can use to turn on wifi.

I think that's much tidier than just exiting the app, as that means if they get the "no wifi" warning the app assists them by providing an option to enable it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜