本文整理汇总了Java中android.net.wifi.p2p.WifiP2pManager.ActionListener类的典型用法代码示例。如果您正苦于以下问题:Java ActionListener类的具体用法?Java ActionListener怎么用?Java ActionListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ActionListener类属于android.net.wifi.p2p.WifiP2pManager包,在下文中一共展示了ActionListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connect
import android.net.wifi.p2p.WifiP2pManager.ActionListener; //导入依赖的package包/类
protected void connect(WifiP2pConfig config) {
toast("みつけた!");
manager.connect(channel, config, new ActionListener() {
@Override
public void onSuccess() {
// WiFiDirectBroadcastReceiver will notify us. Ignore for now.
Log.i(TAG,"p2p connect(try) success");
}
@Override
public void onFailure(int reasonCode) {
Log.i(TAG,"p2p connect(try) failure" + reasonCode);
}
});
}
示例2: connect
import android.net.wifi.p2p.WifiP2pManager.ActionListener; //导入依赖的package包/类
@Override
public void connect(WifiP2pConfig config) {
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(WiFiDirectActivity.this, "Connect failed. Retry.",
Toast.LENGTH_SHORT).show();
}
});
}
示例3: disconnect
import android.net.wifi.p2p.WifiP2pManager.ActionListener; //导入依赖的package包/类
@Override
public void disconnect() {
final DeviceDetailFragment fragment = (DeviceDetailFragment) getFragmentManager()
.findFragmentById(R.id.frag_detail);
fragment.resetViews();
manager.removeGroup(channel, new ActionListener() {
@Override
public void onFailure(int reasonCode) {
Log.d(TAG, "Disconnect failed. Reason :" + reasonCode);
}
@Override
public void onSuccess() {
fragment.getView().setVisibility(View.GONE);
}
});
}
示例4: onStop
import android.net.wifi.p2p.WifiP2pManager.ActionListener; //导入依赖的package包/类
@Override
protected void onStop() {
if (manager != null && channel != null) {
manager.removeGroup(channel, new ActionListener() {
@Override
public void onFailure(int reasonCode) {
Log.d(TAG, "Disconnect failed. Reason :" + reasonCode);
}
@Override
public void onSuccess() {
}
});
}
super.onStop();
}
示例5: startRegistrationAndDiscovery
import android.net.wifi.p2p.WifiP2pManager.ActionListener; //导入依赖的package包/类
/**
* Registers a local service and then initiates a service discovery
*/
private void startRegistrationAndDiscovery() {
Map<String, String> record = new HashMap<String, String>();
record.put(TXTRECORD_PROP_AVAILABLE, "visible");
WifiP2pDnsSdServiceInfo service = WifiP2pDnsSdServiceInfo.newInstance(
SERVICE_INSTANCE, SERVICE_REG_TYPE, record);
manager.addLocalService(channel, service, new ActionListener() {
@Override
public void onSuccess() {
appendStatus("Added Local Service");
}
@Override
public void onFailure(int error) {
appendStatus("Failed to add a service");
}
});
discoverService();
}
示例6: seekPeers
import android.net.wifi.p2p.WifiP2pManager.ActionListener; //导入依赖的package包/类
/**
* Issue a request to the WifiP2pManager to start discovering peers.
* This is an internal method. To turn on/off peer discovery from higher
* level application code, call setSeekingDesired(true/false).
*/
private void seekPeers() {
// DO NOT SUBMIT
// Switched this to be &&
if (!getSeeking() && lastSeekingWasLongAgo()) {
setSeeking(true);
touchLastSeekingTime();
stopwatch.reset();
stopwatch.start();
mWifiP2pManager.discoverPeers(mWifiP2pChannel, new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
Log.d(TAG, "Discovery initiated");
}
@Override
public void onFailure(int reasonCode) {
Log.d(TAG, "Discovery failed: " + reasonCode);
setSeeking(false);
stopSeekingPeers();
}
});
} else {
Log.v(TAG, "Attempted to seek peers while already seeking, not doing it.");
}
}
示例7: stopSeekingPeers
import android.net.wifi.p2p.WifiP2pManager.ActionListener; //导入依赖的package包/类
/**
* Issue a request to the WifiP2pManager to stop discovering peers.
* This is an internal method. To turn on/off peer discovery from higher
* level application code, call setSeekingDesired(true/false).
*/
private void stopSeekingPeers() {
if(getSeeking()) {
log.info("Stopped seeking peers");
Log.d("peerDebug","Stopped seeking peers");
mWifiP2pManager.stopPeerDiscovery(mWifiP2pChannel, new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
log.debug("Discovery stopped successfully.");
setSeeking(false);
}
@Override
public void onFailure(int reasonCode) {
log.debug("Failed to stop peer discovery? Reason: " + reasonCode);
}
});
}
}
示例8: connect
import android.net.wifi.p2p.WifiP2pManager.ActionListener; //导入依赖的package包/类
@Override
public void connect(WifiP2pConfig config) {
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(WiFiDirectActivity.this, "Connect failed. Retry.",
Toast.LENGTH_SHORT).show();
}
});
}
示例9: discoverDevice
import android.net.wifi.p2p.WifiP2pManager.ActionListener; //导入依赖的package包/类
public void discoverDevice() {
Log.d(TAG, "WifiP2pHelper-->discoverDevice()");
if (!isWifiOn()) {
toggleWifi(true);
}
if (isConnected) {
Log.d(TAG, "WifiP2pHelper-->discoverDevice ended-->isConnected=true");
return;
}
handler.sendEmptyMessage(WIFIP2P_DEVICE_DISCOVERING);
manager.discoverPeers(channel, new WifiP2pManager.ActionListener() {
@Override
public void onSuccess() {
}
@Override
public void onFailure(int reasonCode) {
Log.d(TAG, "WifiP2pHelper-->discoverDevice failed reasonCode=" + reasonCode);
}
});
}
示例10: release
import android.net.wifi.p2p.WifiP2pManager.ActionListener; //导入依赖的package包/类
public void release() {
Log.d(TAG, "WifiP2pHelper-->release()");
try {
this.serverSocket.close();
} catch (Exception e) {
}
if(fileReceiveAsyncTask!=null) {
fileReceiveAsyncTask.cancel(true);
}
if(fileSendAsyncTask!=null) {
fileSendAsyncTask.cancel(true);
}
manager.removeGroup(channel, new ActionListener() {
@Override
public void onFailure(int reasonCode) {
Log.d(TAG, "Disconnect failed. Reason :" + reasonCode);
}
@Override
public void onSuccess() {
}
});
}
示例11: connect
import android.net.wifi.p2p.WifiP2pManager.ActionListener; //导入依赖的package包/类
/**
* Connect to the desired peer.
*
* @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();
}
});
}
示例12: disconnect
import android.net.wifi.p2p.WifiP2pManager.ActionListener; //导入依赖的package包/类
/** Disconnect from Wifi Direct. */
private void disconnect() {
// Now I'm disconnected.
isConnected = false;
// Remove this Wifi Direct group.
manager.removeGroup(channel, new ActionListener() {
@Override
public void onFailure(int reasonCode) {
Log.d(DEBUG_TAG, "Disconnect failed. Reason :" + reasonCode);
}
@Override
public void onSuccess() {
Log.d(DEBUG_TAG, "Disconnected and group removed");
}
});
}
示例13: connectP2p
import android.net.wifi.p2p.WifiP2pManager.ActionListener; //导入依赖的package包/类
public synchronized void connectP2p(WifiClientP2pService peer) {
Log.d(TAG,"inside connectp2p ");
/***auto device list***/
/***auto device list***/
Log.d(TAG,"device address: "+peer.getDevice().deviceAddress);
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = peer.getDevice().deviceAddress;
config.wps.setup = WpsInfo.PBC;
//Toast.makeText(getApplicationContext(), "Trying to connect with "+config.deviceAddress, Toast.LENGTH_SHORT).show();
if (serviceRequest != null)
manager.removeServiceRequest(channel, serviceRequest,new ActionListener() {
public void onSuccess() { }
public void onFailure(int arg0) { }
});
manager.connect(channel, config, new ActionListener() {
public void onSuccess() { Log.d(TAG,"Connecting to device"); }
public void onFailure(int errorCode) { Log.d(TAG,"failed Connecting to device"); }
});
/***auto device list***/
/***auto device list***/
}
示例14: disconnectP2p
import android.net.wifi.p2p.WifiP2pManager.ActionListener; //导入依赖的package包/类
private void disconnectP2p(){
Log.d(TAG,"inside disconnectP2p ");
if (manager != null && channel != null) {
manager.removeGroup(channel, new ActionListener() {
@Override
public void onFailure(int reasonCode) {
Log.d(TAG, "Disconnect failed. Reason :" + reasonCode);
}
@Override
public void onSuccess() {
Log.d(TAG, "Disconnect sucessful.");
}
});
}
p2pconnected=false;
}
示例15: onConnectionRequested
import android.net.wifi.p2p.WifiP2pManager.ActionListener; //导入依赖的package包/类
/**
* Callback that reports connection attempts.
* <p/>
* The device parameter provides information about the remote
* device that is trying to form a P2P group. The config
* parameter describes the type of connection being made.
* <p/>
* To accept a connection request, call manager.connect.
* config.wps.pin should be assigned within this method for
* PIN-based group formation before passing the config to
* manager.connect.
*/
@SuppressWarnings("unused")
public void onConnectionRequested(WifiP2pDevice device, WifiP2pConfig config) {
Log.d(TAG, "onConnectionRequested");
Log.d(TAG, " device: " + device.deviceAddress + " " + device.deviceName);
Log.d(TAG, " config: " + config.wps.setup + " " + config.wps.pin);
manager.connect(channel, config, new ActionListener() {
@Override
public void onSuccess() {
// WiFiDirectBroadcastReceiver will notify us. Ignore for now.
}
@Override
public void onFailure(int reason) {
Log.d(TAG, "Connect failed");
}
});
}