List of usage examples for android.net.wifi WpsInfo PBC
int PBC
To view the source code for android.net.wifi WpsInfo PBC.
Click Source Link
From source file:com.alanddev.gmscall.fragment.DeviceDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mContentView = inflater.inflate(R.layout.device_detail, null); mContentView.findViewById(R.id.btn_connect).setOnClickListener(new View.OnClickListener() { @Override/*from w w w . j a v a 2 s. c om*/ public void onClick(View v) { WifiP2pConfig config = new WifiP2pConfig(); config.deviceAddress = device.deviceAddress; config.wps.setup = WpsInfo.PBC; if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } progressDialog = ProgressDialog.show(getActivity(), "Press back to cancel", "Connecting to :" + device.deviceAddress, true, true // new DialogInterface.OnCancelListener() { // // @Override // public void onCancel(DialogInterface dialog) { // ((DeviceActionListener) getActivity()).cancelDisconnect(); // } // } ); ((DeviceListFragment.DeviceActionListener) getParentFragment()).connect(config); } }); mContentView.findViewById(R.id.btn_disconnect).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((DeviceListFragment.DeviceActionListener) getParentFragment()).disconnect(); } }); mContentView.findViewById(R.id.btn_start_client).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Allow user to pick an image from Gallery or other // registered apps Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); startActivityForResult(intent, CHOOSE_FILE_RESULT_CODE); } }); return mContentView; }
From source file:com.example.healthplus.wifidirect.DeviceDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mContentView = inflater.inflate(R.layout.device_detail, null); mContentView.findViewById(R.id.btn_connect).setOnClickListener(new View.OnClickListener() { @Override// w ww . j a v a 2 s . c o m public void onClick(View v) { WifiP2pConfig config = new WifiP2pConfig(); config.deviceAddress = device.deviceAddress; config.wps.setup = WpsInfo.PBC; if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } progressDialog = ProgressDialog.show(getActivity(), "Press back to cancel", "Connecting to :" + device.deviceAddress, true, true // new DialogInterface.OnCancelListener() { // // @Override // public void onCancel(DialogInterface dialog) { // ((DeviceActionListener) getActivity()).cancelDisconnect(); // } // } ); ((DeviceActionListener) getActivity()).connect(config); } }); mContentView.findViewById(R.id.btn_disconnect).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((DeviceActionListener) getActivity()).disconnect(); } }); mContentView.findViewById(R.id.btn_start_client).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Allow user to pick an image from Gallery or other // registered apps //Intent intent = new Intent(Intent.ACTION_GET_CONTENT); //Log.d(WiFiDirectActivity.TAG, "Reached here Richa1"); //intent.setType("image/*"); //intent.setType("text/plain"); //startActivityForResult(intent, CHOOSE_FILE_RESULT_CODE); //Log.d(WiFiDirectActivity.TAG, "Reached here Richa2"); sendFile(); } }); return mContentView; }
From source file:com.example.android.wifidirect.DeviceDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mContentView = inflater.inflate(R.layout.device_detail, null); mContentView.findViewById(R.id.btn_connect).setOnClickListener(new View.OnClickListener() { @Override//from ww w . j a v a 2 s .c o m public void onClick(View v) { WifiP2pConfig config = new WifiP2pConfig(); config.deviceAddress = device.deviceAddress; config.wps.setup = WpsInfo.PBC; if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } progressDialog = ProgressDialog.show(getActivity(), "Press back to cancel", "Connecting to :" + device.deviceAddress, true, true // new DialogInterface.OnCancelListener() { // // @Override // public void onCancel(DialogInterface dialog) { // ((DeviceActionListener) getActivity()).cancelDisconnect(); // } // } ); ((DeviceActionListener) getActivity()).connect(config); } }); mContentView.findViewById(R.id.btn_send_data); mContentView.findViewById(R.id.btn_disconnect).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((DeviceActionListener) getActivity()).disconnect(); } }); mContentView.findViewById(R.id.btn_start_client).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Allow user to pick an image from Gallery or other // registered apps Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); startActivityForResult(intent, CHOOSE_FILE_RESULT_CODE); } }); return mContentView; }
From source file:it.polimi.wifidirect.DeviceDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mContentView = inflater.inflate(R.layout.device_detail, container, false); this.updateThisDevice(); //click connect's button mContentView.findViewById(R.id.btn_connect).setOnClickListener(new View.OnClickListener() { @Override/* w ww . j a va2 s . c om*/ public void onClick(View v) { WifiP2pConfig config = new WifiP2pConfig(); config.deviceAddress = device.getP2pDevice().deviceAddress; config.wps.setup = WpsInfo.PBC; if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } progressDialog = ProgressDialog.show(getActivity(), "Press back to cancel", "Connecting to :" + device.getP2pDevice().deviceAddress, true, true); ((DeviceListFragment.DeviceActionListener) getActivity()).connect(config); } }); mContentView.findViewById(R.id.btn_disconnect).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ClientList.getInstance().getList().clear(); ((DeviceListFragment.DeviceActionListener) getActivity()).disconnect(); } }); mContentView.findViewById(R.id.btn_start_client).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Allow user to pick an image from Gallery or other // registered apps Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("video/*, image/*"); startActivityForResult(intent, CHOOSE_FILE_RESULT_CODE); } }); //click on connect's button mContentView.findViewById(R.id.btn_start_ping_pong).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PingPongDialog pingPongDialog = (PingPongDialog) getFragmentManager() .findFragmentByTag("pingPongDialog"); if (pingPongDialog == null) { pingPongDialog = PingPongDialog.newInstance(); pingPongDialog.setTargetFragment(fragment, PINGPONG); pingPongDialog.show(getFragmentManager(), "pingPongDialog"); getFragmentManager().executePendingTransactions(); } } }); mContentView.findViewById(R.id.btn_start_ping_pong).setVisibility(View.GONE); RecyclerView mRecyclerView = (RecyclerView) mContentView.findViewById(R.id.clientRecyclerView); LinearLayoutManager mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); mRecyclerView.setLayoutManager(mLayoutManager); // allows for optimizations if all item views are of the same size. mRecyclerView.setHasFixedSize(true); mAdapter = new WiFiDetailClientListAdapter(); mRecyclerView.setAdapter(mAdapter); mRecyclerView.setItemAnimator(new DefaultItemAnimator()); return mContentView; }
From source file:com.example.swiftdatahop.Fragment_PeerDetails.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.d(TAG, "oncreateview attempted"); mContentView = inflater.inflate(R.layout.tdf_peerdetails, null); // Show the dummy content as text in a TextView. if (mItem != null) { ((TextView) mContentView.findViewById(R.id.task_detail)).setText(mItem.content); }// www . j a v a2 s . c o m mContentView.findViewById(R.id.btn_connect).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.d(TAG, "onclick connect attempted"); if (device == null) return; //todo - add code to remove connect/disconnect button if no device WifiP2pConfig config = new WifiP2pConfig(); config.deviceAddress = device.deviceAddress; config.wps.setup = WpsInfo.PBC; if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } progressDialog = ProgressDialog.show(getActivity(), "Press back to cancel", "Connecting to :" + device.deviceAddress, true, true); ((DeviceActionListener) getActivity()).connect(config); } }); mContentView.findViewById(R.id.btn_disconnect).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((DeviceActionListener) getActivity()).disconnect(); } }); mContentView.findViewById(R.id.btn_send_file).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (info != null) sendFile(info); } }); mContentView.findViewById(R.id.btn_receive_file).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { receiveFile(); } }); mContentView.findViewById(R.id.btn_set_upstream_device).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (device == null) { Log.e("TaskDetailFragment_PeerDetails", "Set upstream device failed with null device"); return; } WifiP2pDevice downstream = mAppData.getDownStreamDevice(); if (downstream != null) { if (downstream.deviceName.equals(device.deviceName)) { Log.e("TaskDetailFragment_PeerDetails", "Upstream device chosen, matches downstream device " + downstream.deviceName); showToastShort("Warning: upstream device chosen, matches downstream device " + downstream.deviceName); } } mAppData.setUpStreamDevice(device); Log.d("TaskDetailFragment_PeerDetails", "Upstream device set " + device.deviceName); showToastShort("Upstream device set " + device.deviceName); } }); mContentView.findViewById(R.id.btn_set_downstream_device).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (device == null) { Log.e("TaskDetailFragment_PeerDetails", "Set downstream device failed with null device."); return; } else { WifiP2pDevice upStream = mAppData.getUpStreamDevice(); if (upStream != null) { if (upStream.deviceName.equals(device.deviceName)) { Log.e("TaskDetailFragment_PeerDetails", "Downstream device chosen, matches downstream device " + upStream.deviceName); showToastShort("WARNING: Downstream device chosen, matches upStream device " + upStream.deviceName); } } mAppData.setDownStreamDevice(device); showToastShort("Downstream device set."); Log.d("TaskDetailFragment_PeerDetails", "Downstream device set " + device.deviceName); } } }); return mContentView; }
From source file:com.material.katha.wifidirectmp3.DeviceDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { filelist();/*from w w w . jav a2s . c om*/ FileInputStream inputStream = null; try { inputStream = getActivity().openFileInput("myfile"); } catch (FileNotFoundException e) { e.printStackTrace(); } InputStreamReader inputStreamReader = new InputStreamReader(inputStream); mContentView = inflater.inflate(R.layout.device_detail, null); Log.d("katha", "2"); mContentView.findViewById(R.id.btn_connect).setOnClickListener(new View.OnClickListener() { // @Override public void onClick(View v) { s_count = 0; c_count = 0; WifiP2pConfig config = new WifiP2pConfig(); config.deviceAddress = device.deviceAddress; config.wps.setup = WpsInfo.PBC; if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } progressDialog = ProgressDialog.show(getActivity(), "Press back to cancel", "Connecting to :" + device.deviceName, true, true); // // new DialogInterface.OnCancelListener() { // // @Override // public void onCancel(DialogInterface dialog) { // ((DeviceActionListener) getActivity()).cancelDisconnect(); // } // } devicename = device.deviceName; Toast.makeText(getActivity(), devicename, Toast.LENGTH_LONG).show(); ((DeviceListFragment.DeviceActionListener) getActivity()).connect(config); } }); mContentView.findViewById(R.id.btn_disconnect).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((DeviceListFragment.DeviceActionListener) getActivity()).disconnect(); s_count = 0; c_count = 0; DeviceListFragment.state = "avail"; } }); mContentView.findViewById(R.id.btn_resume).setClickable(false); mContentView.findViewById(R.id.btn_resume).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (pause % 2 == 0) { pause++; Toast.makeText(getActivity(), "Paused !!!", Toast.LENGTH_SHORT).show(); Button b = (Button) v.findViewById(R.id.btn_resume); b.setClickable(false); b.setVisibility(View.GONE); b.setText("Resume"); } else { pause++; pd.show(); Toast.makeText(getActivity(), "Resumed !!!", Toast.LENGTH_SHORT).show(); Button b = (Button) v.findViewById(R.id.btn_resume); b.setClickable(false); b.setVisibility(View.GONE); b.setText("Resume"); } } }); mContentView.findViewById(R.id.btn_start_client).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // // Allow user to pick an image from Gallery or other // // registered apps // ///////////////////////////////// // ContentResolver cr = getActivity().getContentResolver(); // InputStream is = null; // int fsize = 0; //// try { //// is=cr.openInputStream(Uri.parse(new File("/data/data/com.material.katha.wifidirectmp3/app_Shared/Screenshot_2016-04-11-08-25-12.png").toString())); //// // is = cr.openInputStream(uri); //// fsize = is.available(); //// //// // Log.d(WiFiDirectActivity.TAG,"File size is:"+is.available()+" "+f.getName()+"uri "+uri + "f "+ f+ "file name " +f.getName()); //// } catch (FileNotFoundException e) { //// e.printStackTrace(); //// } catch (IOException e) { //// e.printStackTrace(); //// } // // //Log.d("katha", fileext + "fileext"); // //;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;change fileext = abc.substring(abc.lastIndexOf('.')); // // /*progressDialog = new ProgressDialog(getActivity()); // progressDialog.setMessage("Sending file:"+abc); // progressDialog.show(); // */ // // // progressDialog = ProgressDialog.show(getActivity(), "Sending","Copying file :" + fileext, true, true); // // makeText(getActivity(), fileext, LENGTH_LONG).show(); // TextView statusText = (TextView) mContentView.findViewById(R.id.status_text); // // statusText.setText("Sending: " + uri); // // String devicename = "abc"; // devicename = device.deviceName; // // Toast.makeText(getActivity(),devicename,Toast.LENGTH_LONG).show(); // // // Log.d("WiFiDirectActivity", "Intent----------- " + Uri.parse(new File("DCIM/Camera/IMG_20160118_090231.jpg").toString())); // Intent serviceIntent = new Intent(getActivity(), FileTransferService.class); // serviceIntent.setAction(FileTransferService.ACTION_SEND_FILE); // //Log.d("WiFiDirectActivity", "Action" + FileTransferService.ACTION_SEND_FILE + "\n\n\n\n"); // ////////////////////serviceIntent.putExtra(FileTransferService.EXTRAS_FILE_PATH, uri.toString()); // //serviceIntent.putExtra(FileTransferService.EXTRAS_FILE_PATH,"DCIM/Camera/IMG_20160118_090231.jpg"); // // //serviceIntent.putExtra(FileTransferService.FILE_SIZE, fsize); // // serviceIntent.putExtra(FileTransferService.device_name,devicename); // serviceIntent.putExtra(FileTransferService.EXTRAS_GROUP_OWNER_PORT, 8988); // String localip = getDottedDecimalIP(getLocalIPAddress()); // Log.d("WiFiDirectActivity", "DEVICE_NAME: " + devicename); // serviceIntent.putExtra(FileTransferService.DEVICE_NAME, devicename); // // if (localip.equals("192.168.49.1")) { // Log.d("WiFiDirectActivity", "Flag is 0."); // // devicename = device.deviceName; // serviceIntent.putExtra(FileTransferService.EXTRAS_GROUP_OWNER_ADDRESS, client_ip); // serviceIntent.putExtra(FileTransferService.Client_add, client_ip); // ; // } else { // Log.d("WiFiDirectActivity", "Flag is 1."); // //devicename = device.deviceName; // // Toast.makeText(getActivity(),devicename,Toast.LENGTH_LONG).show(); // serviceIntent.putExtra(FileTransferService.EXTRAS_GROUP_OWNER_ADDRESS, // info.groupOwnerAddress.getHostAddress()); // serviceIntent.putExtra(FileTransferService.Client_add, localip); // // } // getActivity().startService(serviceIntent); // Log.d("WiFiDirectActivity","here"); ////////////////////////////////// if (!info.groupOwnerAddress.getHostAddress().equals("")) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); startActivityForResult(intent, CHOOSE_FILE_RESULT_CODE); } } }); return mContentView; }
From source file:com.github.peejweej.androidsideloading.fragments.DeviceDetailFragment.java
private void connect() { WifiP2pConfig config = new WifiP2pConfig(); config.deviceAddress = device.deviceAddress; config.wps.setup = WpsInfo.PBC; if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss();// w w w. j a va 2 s . c om } progressDialog = ProgressDialog.show(getActivity(), "Press back to cancel", "Connecting to :" + device.deviceAddress, true, true // new DialogInterface.OnCancelListener() { // // @Override // public void onCancel(DialogInterface dialog) { // ((DeviceActionListener) getActivity()).cancelDisconnect(); // } // } ); ((DevicesListFragment.DeviceActionListener) getActivity()).connect(config); }
From source file:org.distantshoresmedia.wifiDirect.DeviceDetailFragment.java
private void connect() { WifiP2pConfig config = new WifiP2pConfig(); config.deviceAddress = device.deviceAddress; config.wps.setup = WpsInfo.PBC; if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss();/*w w w . java 2 s . c om*/ } progressDialog = ProgressDialog.show(getActivity(), "Press back to cancel", "Connecting to :" + device.deviceAddress, true, true // new DialogInterface.OnCancelListener() { // // @Override // public void onCancel(DialogInterface dialog) { // ((DeviceActionListener) getActivity()).cancelDisconnect(); // } // } ); ((DeviceListFragment.DeviceActionListener) getActivity()).connect(config); }
From source file:it.polimi.deib.p2pchat.discovery.chatmessages.waitingtosend.discovery.MainActivity.java
/** * Method that connects to the specified service. * * @param service The {@link WiFiP2pService} * to which you want to connect. *//*from ww w. ja v a 2s . c o m*/ private void connectP2p(WiFiP2pService service) { Log.d(TAG, "connectP2p, tabNum before = " + tabNum); if (DestinationDeviceTabList.getInstance().containsElement(new P2pDestinationDevice(service.getDevice()))) { this.tabNum = DestinationDeviceTabList.getInstance() .indexOfElement(new P2pDestinationDevice(service.getDevice())) + 1; } if (this.tabNum == -1) { Log.d("ERROR", "ERROR TABNUM=-1"); //only for testing purposes. } WifiP2pConfig config = new WifiP2pConfig(); config.deviceAddress = service.getDevice().deviceAddress; config.wps.setup = WpsInfo.PBC; config.groupOwnerIntent = 10; //because i want that this device is the Server. if (serviceRequest != null) { manager.removeServiceRequest(channel, serviceRequest, new CustomizableActionListener(MainActivity.this, "connectP2p", null, "RemoveServiceRequest success", null, "removeServiceRequest failed")); } manager.connect(channel, config, new CustomizableActionListener(MainActivity.this, "connectP2p", null, "Connecting to service", null, "Failed connecting to service")); }
From source file:com.prgpascal.qrdatatransfer.TransferActivity.java
/** * Connect to the desired peer.//from ww w . java 2s .c o m * * @param deviceMacAddress the MAC address of the Server peer to connect with. */ private void connect(String deviceMacAddress) { // Create other device config WifiP2pConfig config = new WifiP2pConfig(); config.deviceAddress = deviceMacAddress; config.wps.setup = WpsInfo.PBC; config.groupOwnerIntent = 0; // I want the other device to be the Group Owner !! // Perform connection manager.connect(channel, config, new ActionListener() { @Override public void onSuccess() { // WiFiDirectBroadcastReceiver will notify us. Ignore for now. } @Override public void onFailure(int reason) { Toast.makeText(TransferActivity.this, R.string.aqrdt_error_connection_failed, Toast.LENGTH_SHORT) .show(); // Error during connection to the peer. Force the Activity to be finished. finishTransmissionWithError(); } }); }