@Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_BACK: Closed = true; if (connMgrService != null) { connMgrService.onConnectorDestroy(); } finish(); return true; } return super.onKeyDown(keyCode, event); }
public void onSearchStart(DeviceInfo leader) { if (Closed) return; Log.d(TAG, "SEARCH_START1"); if (!isLeader && peerNetData != null && chosenNType != NetInfo.NoNet) { Log.d(TAG, "group member search started, exit connector"); Closed = true; if (connMgrService != null) { connMgrService.onConnectorDestroy(); } finish(); if (nfcIntent != null) { // member connects thru NFC, bring up // CnnMgr Intent intent = new Intent(Router.ACTION_CONNECTION_MANAGEMENT); startActivity(intent); } } }
@Override protected void onDestroy() { if (connMgrService != null) { Log.d(TAG, "CtorActivity destroyed"); connMgrService.onConnectorDestroy(); unbindService(mConnection); connMgrService = null; } if (grpMgr != null) { grpMgr.onDestroy(); } // dont destroy connMgrService here // since connMgr will start right away super.onDestroy(); Log.d(TAG, "onDestroyed"); }
void resetChosenNType() { // if (isLeader && connMgrService != null) { connMgrService.stopPeerSearch(); connMgrService.onConnectorDestroy(); } // if (isLeader) { showGroup(2); } // chosenNType = NetInfo.NoNet; wifiBtn.setChecked(false); wifiDirectBtn.setChecked(false); wifiHotspotBtn.setChecked(false); wifiInfo.setText(wifiInfoText); wifiDirectInfo.setText(wifiDirectInfoText); wifiHotspotInfo.setText(wifiHotspotInfoText); }
public Dialog onCreateDialog(int id) { switch (id) { case WIFI_DIRECT_WARNING_DIALOG: return new AlertDialog.Builder(this) .setTitle(R.string.wifidir_warning_title) .setIcon(R.drawable.router_icon) .setMessage(R.string.wifidir_warning) .setPositiveButton( R.string.ok, new Dialog.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { // dialogInterface.dismiss(); removeDialog(WIFI_DIRECT_WARNING_DIALOG); // ask user to turn on wifi direct Log.d(TAG, "ask user to turn on wifi direct"); try { if (Utils.ANDROID_VERSION >= 16) { Intent in = new Intent(Settings.ACTION_WIFI_SETTINGS); startActivity(in); } else { Intent in = new Intent(Settings.ACTION_WIRELESS_SETTINGS); startActivity(in); } } catch (ActivityNotFoundException anf) { Log.d( TAG, "no activity for : Settings.ACTION_WIRELESS_SETTINGS" + anf.getMessage()); Intent in = new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK); startActivity(in); } } }) .setNegativeButton( R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { removeDialog(WIFI_DIRECT_WARNING_DIALOG); } }) .create(); case WIFI_CONNECTOR_FAIL_DIALOG: if (peerNetData == null) { Closed = true; if (connMgrService != null) { connMgrService.onConnectorDestroy(); } finish(); return null; } CharSequence msg1 = getResources().getText(R.string.wifi_conn_fail_msg1); CharSequence msg2 = getResources().getText(R.string.wifi_conn_fail_msg2); return new AlertDialog.Builder(this) .setTitle(R.string.wifi_conn_fail_title) .setIcon(R.drawable.router_icon) .setMessage(msg1 + " " + peerNetData.ssid + msg2) .setNegativeButton( R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { removeDialog(WIFI_CONNECTOR_FAIL_DIALOG); Closed = true; if (connMgrService != null) { connMgrService.onConnectorDestroy(); } finish(); } }) .create(); default: break; } return null; }