当前位置: 首页>>代码示例>>Java>>正文


Java WifiP2pManager.initialize方法代码示例

本文整理汇总了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();
}
 
开发者ID:mDL-ILP,项目名称:mDL-ILP,代码行数:17,代码来源:WiFiDirectConnection.java

示例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);
    }
 
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:34,代码来源:FileTransferService.java

示例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;
}
 
开发者ID:mDL-ILP,项目名称:mDL-ILP,代码行数:16,代码来源:WiFiDirectConnection.java

示例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);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:16,代码来源:WiFiDirectActivity.java

示例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();

}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:24,代码来源:WiFiServiceDiscoveryActivity.java

示例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);
    
    
}
 
开发者ID:coderminer,项目名称:Demo_Public,代码行数:18,代码来源:WiFiDirectActivity.java

示例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();
}
 
开发者ID:lucky-code,项目名称:Practice,代码行数:11,代码来源:WifiP2pHelper.java

示例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);
}
 
开发者ID:lucky-code,项目名称:Practice,代码行数:19,代码来源:WiFiDirectActivity.java

示例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);
}
 
开发者ID:lucky-code,项目名称:Practice,代码行数:18,代码来源:WiFiDirectActivity.java

示例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);
}
 
开发者ID:niyueming,项目名称:WiFiP2PDemo,代码行数:22,代码来源:MainActivity.java

示例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();
}
 
开发者ID:jphacks,项目名称:TK_1701,代码行数:29,代码来源:WiFiDirect.java

示例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");
}
 
开发者ID:Crash-Test-Buddies,项目名称:WiFi-Buddy,代码行数:15,代码来源:WifiDirectHandler.java

示例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);
}
 
开发者ID:lucky-code,项目名称:Practice,代码行数:16,代码来源:WiFiDirectActivity.java

示例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();
}
 
开发者ID:prgpascal,项目名称:android-qr-data-transfer,代码行数:28,代码来源:TransferActivity.java

示例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);
}
 
开发者ID:n8fr8,项目名称:LittleBitLouder,代码行数:6,代码来源:WifiP2pSender.java


注:本文中的android.net.wifi.p2p.WifiP2pManager.initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。