[英]Android: Send 'waiting' string data to database after clicked submit button
[英]Send user to preferences on Android after button is clicked
我有一個Android應用程序,要求用戶連接到Internet。 如果用戶不在線,則該應用程序將顯示一個AlertDialog,其中顯示:“您必須連接到Internet才能使用此應用程序”。 在該AlertDialog中,我有一個按鈕。 我可以通過一些方式將用戶發送到首選項,以便用戶可以打開互聯網並返回我的應用程序嗎? 因此,當用戶返回時,我只需運行我的方法即可從所使用的服務中獲取信息。
使用此代碼:
startActivity(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK));
編輯:您可以使用:
startActivityForResult(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK), PICK_WIFI_REQUEST_CODE);
然后覆蓋:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//Check if you have internet
//... proceed to next Activity
}
使用當前的班級活動和WifiManager常量創建一個新的Intent,以搜索網絡/選擇網絡。 開始活動並等待結果。
Intent intent = new Intent(activity.this, WifiManager.ACTION_PICK_WIFI_NETWORK);
startActivityForResult(intent,1)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.