本文整理汇总了Java中android.net.wifi.p2p.WifiP2pManager.initialize方法的典型用法代码示例。如果您正苦于以下问题:Java WifiP2pManager.initialize方法的具体用法?Java WifiP2pManager.initialize怎么用?Java WifiP2pManager.initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.net.wifi.p2p.WifiP2pManager
的用法示例。
在下文中一共展示了WifiP2pManager.initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: WiFiDirectConnection
import android.net.wifi.p2p.WifiP2pManager; //导入方法依赖的package包/类
public WiFiDirectConnection(Activity activity, WiFiTransfer transfer) {
this.activity = activity;
this.transfer = transfer;
intentFilter = new IntentFilter();
intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);
manager = (WifiP2pManager) activity.getSystemService(Context.WIFI_P2P_SERVICE);
channel = manager.initialize(activity.getApplicationContext(), activity.getMainLooper(), channelListener);
channelListener = new ChannelListener();
connectionInfoListener = new ConnectionInfoListener();
}
示例2: onCreate
import android.net.wifi.p2p.WifiP2pManager; //导入方法依赖的package包/类
public void onCreate(){
super.onCreate();
mManager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
mChannel = mManager.initialize(this, getMainLooper(), null);
mReceiver = new WiFiDirectBroadcastReceiver(mManager, mChannel, this);
mIntentFilter = new IntentFilter();
mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);
WifiManager wm = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
mWiFiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL , "WiFiDirectLock");
mHandler = new Handler();
registerReceiver(mReceiver, mIntentFilter);
// try {
// Method enableP2p = WifiP2pManager.class.getMethod("enableP2p", Channel.class);
// enableP2p.invoke(mManager, mChannel);
// } catch (IllegalArgumentException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// } catch (InvocationTargetException e) {
// e.printStackTrace();
// } catch (NoSuchMethodException e) {
// e.printStackTrace();
// }
// mManager.enableP2p(mChannel);
}
示例3: runSetupSteps
import android.net.wifi.p2p.WifiP2pManager; //导入方法依赖的package包/类
public void runSetupSteps() throws RemoteConnectionException {
intentFilter = new IntentFilter();
intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);
manager = (WifiP2pManager) activity.getSystemService(Context.WIFI_P2P_SERVICE);
channel = manager.initialize(activity.getApplicationContext(), activity.getMainLooper(), null);
peerListener = new PeerListener();
connectionListener = new ConnectionListener();
setupCompleted = true;
}
示例4: onCreate
import android.net.wifi.p2p.WifiP2pManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// add necessary intent values to be matched.
intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);
manager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
channel = manager.initialize(this, getMainLooper(), null);
}
示例5: onCreate
import android.net.wifi.p2p.WifiP2pManager; //导入方法依赖的package包/类
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
statusTxtView = (TextView) findViewById(R.id.status_text);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
intentFilter
.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
intentFilter
.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);
manager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
channel = manager.initialize(this, getMainLooper(), null);
startRegistrationAndDiscovery();
servicesList = new WiFiDirectServicesList();
getFragmentManager().beginTransaction()
.add(R.id.container_root, servicesList, "services").commit();
}
示例6: onCreate
import android.net.wifi.p2p.WifiP2pManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.main);
//��ʼ��WifiP2pManager
mManager = (WifiP2pManager)getSystemService(Context.WIFI_P2P_SERVICE);
mChannel = mManager.initialize(this, getMainLooper(), null);
//������Ҫ������action
intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);
}
示例7: WifiP2pHelper
import android.net.wifi.p2p.WifiP2pManager; //导入方法依赖的package包/类
public WifiP2pHelper(final MainActivity activity, Handler handler) {
this.activity = activity;
this.handler = handler;
manager = (WifiP2pManager) activity
.getSystemService(Context.WIFI_P2P_SERVICE);
channel = manager.initialize(activity, activity.getMainLooper(), null);
deviceList = new ArrayList<WifiP2pDevice>();
sendingFileList = new ArrayList<>();
updateWifiMac();
}
示例8: onCreate
import android.net.wifi.p2p.WifiP2pManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_wifidirect);
// add necessary intent values to be matched.
intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);
intentFilter_update.addAction("UPDATE_PEERS");
manager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
channel = manager.initialize(this, getMainLooper(), null);
}
示例9: onCreate
import android.net.wifi.p2p.WifiP2pManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.wifi_activity_main);
// add necessary intent values to be matched.
intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);
intentFilter_update.addAction("UPDATE_PEERS");
manager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
channel = manager.initialize(this, getMainLooper(), null);
}
示例10: onCreate
import android.net.wifi.p2p.WifiP2pManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initFilter();
mManager = (WifiP2pManager) getSystemService(WIFI_P2P_SERVICE);
mChannel = mManager.initialize(this, getMainLooper(), new WifiP2pManager.ChannelListener() {
@Override
public void onChannelDisconnected() {
Log.e("initialize","onChannelDisconnected");
mManager.initialize(MainActivity.this,getMainLooper(),this);
}
});
thisDevice = (TextView) findViewById(R.id.thisD);
listView = (ListViewCompat) findViewById(R.id.listView);
adapter = new WifiP2pDeviceAdapter(this,peers);
listView.setAdapter(adapter);
}
示例11: WiFiDirect
import android.net.wifi.p2p.WifiP2pManager; //导入方法依赖的package包/类
public WiFiDirect(Activity activity) {
// app, activity
this.activity = activity;
app = (MeePaApp) activity.getApplication();
// Instantiate
connector = new WiFiDirectConnector(this);
communicator = new WiFiDirectCommunicator(this);
// Register the Intent Filter
intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);
// Get manager & channel Instance
manager = (WifiP2pManager) activity.getSystemService(Context.WIFI_P2P_SERVICE);
channel = manager.initialize(activity, getMainLooper(), null);
// Initialize IDs
updateIDs();
Log.d(TAG,"hello");
//app.setOpponentUserInfo("enpitsublue","n8y6");
//app.setSelfUserInfo("enpitsugreen","bh96");
//app.saveUserInfo();
}
示例12: registerP2p
import android.net.wifi.p2p.WifiP2pManager; //导入方法依赖的package包/类
/**
* Registers the application with the Wi-Fi P2P framework
* Initializes the P2P manager and gets a P2P communication channel
*/
public void registerP2p() {
// Manages Wi-Fi P2P connectivity
wifiP2pManager = (WifiP2pManager) getSystemService(WIFI_P2P_SERVICE);
// initialize() registers the app with the Wi-Fi P2P framework
// Channel is used to communicate with the Wi-Fi P2P framework
// Main Looper is the Looper for the main thread of the current process
channel = wifiP2pManager.initialize(this, getMainLooper(), null);
Log.i(TAG, "Registered with Wi-Fi P2P framework");
}
示例13: onCreate
import android.net.wifi.p2p.WifiP2pManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// add necessary intent values to be matched.
intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);
manager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
channel = manager.initialize(this, getMainLooper(), null);
}
示例14: onCreate
import android.net.wifi.p2p.WifiP2pManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Prevent from Screen rotation
MyCustomScreenOrientationManager.lockScreen(TransferActivity.this);
// First, get the Intent Extras...
checkAndGetIntentExtras(getIntent().getExtras());
// Add the required intent filter values for the WIFI Direct connection
intentFilter = new IntentFilter();
intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION);
// Initialize the WiFiP2PManager and get the Channel
manager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
channel = manager.initialize(this, getMainLooper(), null);
// Delete previous persistent Wifi Direct groups
deletePreviousPersistentGroups();
// Create the layout
createLayout();
}
示例15: setupWifiP2p
import android.net.wifi.p2p.WifiP2pManager; //导入方法依赖的package包/类
public void setupWifiP2p (Context context)
{
mManager = (WifiP2pManager) context.getSystemService(Context.WIFI_P2P_SERVICE);
mChannel = mManager.initialize(context, context.getMainLooper(), null);
}