Example usage for android.content Context WIFI_P2P_SERVICE

List of usage examples for android.content Context WIFI_P2P_SERVICE

Introduction

In this page you can find the example usage for android.content Context WIFI_P2P_SERVICE.

Prototype

String WIFI_P2P_SERVICE

To view the source code for android.content Context WIFI_P2P_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.net.wifi.p2p.WifiP2pManager for handling management of Wi-Fi peer-to-peer connections.

Usage

From source file:org.physical_web.physicalweb.FileBroadcastService.java

private void changeWifiName() {
    String deviceName = "PW-" + mTitle + "-" + mPort;
    if (deviceName.length() > MAX_DEVICE_NAME_LENGTH) {
        deviceName = DEFAULT_DEVICE_NAME + mPort;
    }//  ww w  .j av  a  2s  .  c o m
    try {
        WifiP2pManager manager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
        WifiP2pManager.Channel channel = manager.initialize(this, getMainLooper(), null);
        Class[] paramTypes = new Class[3];
        paramTypes[0] = WifiP2pManager.Channel.class;
        paramTypes[1] = String.class;
        paramTypes[2] = WifiP2pManager.ActionListener.class;
        Method setDeviceName = manager.getClass().getMethod("setDeviceName", paramTypes);
        setDeviceName.setAccessible(true);

        Object arglist[] = new Object[3];
        arglist[0] = channel;
        arglist[1] = deviceName;
        arglist[2] = new WifiP2pManager.ActionListener() {

            @Override
            public void onSuccess() {
                Log.d(TAG, "setDeviceName succeeded");
            }

            @Override
            public void onFailure(int reason) {
                Log.d(TAG, "setDeviceName failed");
            }
        };
        setDeviceName.invoke(manager, arglist);

    } catch (NoSuchMethodException e) {
        Log.d(TAG, e.getMessage());
    } catch (IllegalAccessException e) {
        Log.d(TAG, e.getMessage());
    } catch (IllegalArgumentException e) {
        Log.d(TAG, e.getMessage());
    } catch (InvocationTargetException e) {
        Log.d(TAG, e.getMessage());
    }
}

From source file:com.monkey.entonado.MainActivity.java

/**
 * Inicializa la actividad/*from  ww w  . j a  v a 2  s. c  o  m*/
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    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);

    btnBuscar = (TextView) findViewById(R.id.btnBuscar);
    btnBuscar.setOnClickListener(this);

    radioTitulo = (Button) findViewById(R.id.btnTitulo);
    radioArtista = (Button) findViewById(R.id.btnArtista);

    campoBusqueda = (EditText) findViewById(R.id.campoBusqueda);

    busqueda = (TextView) findViewById(R.id.txtBusqueda);

    out = null;
    in = null;

    canciones = new ArrayList();
    milista = new ArrayList();

    mensajeConexion = "No se estableci la conexion";
    intentoConectar = false;
    ip = "";

}

From source file:com.example.android.listentgt.MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Create the adapter that will return a fragment for each of the three primary sections
    // of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    PACKAGE_NAME = getApplicationContext().getPackageName();

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home/Up button should not be enabled, since there is no hierarchical
    // parent./*www.  j  a  v a  2 s . c  om*/
    actionBar.setHomeButtonEnabled(false);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between different app sections, select the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by the adapter.
        // Also specify this Activity object, which implements the TabListener interface, as the
        // listener for when this tab is selected.
        actionBar.addTab(actionBar.newTab().setText(pages[i]).setTabListener(this));
    }

    //Initalize fragments
    fragment1 = new FragmentPlayList();
    fragment2 = new DeviceListFragment();
    fragment3 = new FragmentSettingsPage();

    //wifiP2pManagerActivity
    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);
}

From source file:com.mstar.tv.tvplayer.philips.option.OptionFirstFragment.java

private void clearScreenShares() {
    mWifiP2pManager = (WifiP2pManager) mContext.getSystemService(Context.WIFI_P2P_SERVICE);
    mChannel = mWifiP2pManager.initialize(mContext, mContext.getMainLooper(), null);
    mWifiP2pManager.removeGroup(mChannel, new WifiP2pManager.ActionListener() {
        @Override/*  w  ww. ja va 2 s .co m*/
        public void onSuccess() {
            // TODO Auto-generated method stub
            showToast(mContext.getResources().getString(R.string.disconnect_success));
            Log.i("PhoneShareReceiver", "???");
        }

        @Override
        public void onFailure(int arg0) {
            // TODO Auto-generated method stub
            showToast(mContext.getResources().getString(R.string.disconnect_failed));
            Log.i("PhoneShareReceiver", "??");
        }
    });
}

From source file:ro.ui.pttdroid.Client_Main.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.client_main);
    userName = (TextView) findViewById(R.id.userName_client);
    title = (TextView) findViewById(R.id.title);
    content = (TextView) findViewById(R.id.content);

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    getActionBar().setBackgroundDrawable(getResources().getDrawable(R.color.bar)); //?

    //???/*from   w  w w .ja  va  2  s.c o  m*/
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    //ml.release();

    /*ImageButton ready_image_guide;
    ready_image_guide=(ImageButton)findViewById(R.id.ready_image_guide); 
            
    ready_image_guide.setOnClickListener(new Button.OnClickListener()  
    {  
        @Override  
        public void onClick(View v) {  
            // TODO Auto-generated method stub  
                   
          change_to_client_online_fragment();
                   
        }  
                  
    }); */
    //getActionBar().setBackgroundDrawable(null);

    System.out.println("start main!!!!!!!!!!");
    Intent intent = this.getIntent();
    //???   
    if_Global_local = intent.getIntExtra("if_Global_local", -2);
    System.out.println("if_Global_local" + if_Global_local);

    try {
        ParseHelper.initParse(this);
        EventBus.getDefault().postSticky("Parse init success!");
    } catch (Exception e) {
        EventBus.getDefault().postSticky("Failed to int parse!");
    }

    /*ImageButton listen_guide = (ImageButton) findViewById(R.id.listen_guide);
            
    listen_guide .setOnClickListener(new View.OnClickListener() {
               public void onClick(View v) {
              
               }});*/

    init();

    /*change_to_client_online_fragment();
    playerIntent = new Intent(this, Client_Player.class);
    startService(playerIntent);
    */

    if (if_Global_local == 1) {
        System.out.println("local");
        if (if_clientL_offline_mode) {

            if_clientL_offline_mode = false;
            change_to_client_online_fragment();
            playerIntent = new Intent(this, Client_Player.class);
            startService(playerIntent);

        }
    }

    if (if_Global_local == 0) {
        System.out.println("global");
        if (if_clientL_offline_mode) {
            if_loading_final = true;
            if_clientL_offline_mode = false;
            microphoneSwitcher.hide();
            change_to_client_Global_online_fragment();
        }
        invalidateOptionsMenu();

    }

    //microphoneSwitcher.hide();

    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);

    filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);

    EventBus.getDefault().register(this);
    // test_connect();

}

From source file:ro.ui.pttdroid.Main.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);/*  ww  w  .ja  v  a  2  s .c  o m*/

    getActionBar().setBackgroundDrawable(null);
    System.out.println("start main!!!!!!!!!!");

    /* mContext = this.getApplicationContext();
       spinner = (Spinner)findViewById(R.id.mySpinner); 
               
       mContext2 = this.getApplicationContext();
       spinner2 = (Spinner)findViewById(R.id.mySpinner2); 
               
       lunchList = new ArrayAdapter<String>(Main.this,android.R.layout.simple_spinner_item, lunch);
       spinner.setAdapter(lunchList);
               
       lunchList2 = new ArrayAdapter<String>(Main.this,android.R.layout.simple_spinner_item, lunch2);
       spinner2.setAdapter(lunchList2);
       */

    try {
        NfcManager managers = (NfcManager) getSystemService(Context.NFC_SERVICE);
        adapter = managers.getDefaultAdapter();
    } catch (Exception e) {
    }
    try {
        ParseHelper.initParse(this);
        EventBus.getDefault().postSticky("Parse init success!");
    } catch (Exception e) {
        EventBus.getDefault().postSticky("Failed to int parse!");
    }
    loadAd();

    init();
    //writing = (ImageView) findViewById(R.id.writing);
    if (if_guider) {
        //   writing.setVisibility(View.VISIBLE);
        //   writing.setBackgroundResource(R.drawable.circle_green);
    }

    btn_test_mp3 = (Button) findViewById(R.id.btn_test_mp3);
    btn_test_mp3.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Mp3Helper mp3Helper = new Mp3Helper("", "");
            mp3Helper.test_start_converting();
        }
    });

    Button button = (Button) findViewById(R.id.force);
    button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            test_socket_server();
        }
    });

    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);

    filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);

    EventBus.getDefault().register(this);
    // test_connect();

}

From source file:com.nest5.businessClient.Initialactivity.java

/**
 * Begins the activity.//from  w  w w.j ava 2s .  com
 */
@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    this.savedInstanceState = savedInstanceState;
    getWindow().setFormat(PixelFormat.RGBA_8888);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER);
    BugSenseHandler.initAndStartSession(Initialactivity.this, "1a5a6af1");
    setContentView(R.layout.swipe_view);
    checkLogin();
    // 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);
    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    dbHelper = new MySQLiteHelper(this);
    ingredientCategoryDatasource = new IngredientCategoryDataSource(dbHelper);
    db = ingredientCategoryDatasource.open();
    ingredientCategories = ingredientCategoryDatasource.getAllIngredientCategory();
    // ingredientCategoryDatasource.close();
    productCategoryDatasource = new ProductCategoryDataSource(dbHelper);
    productCategoryDatasource.open(db);
    productsCategories = productCategoryDatasource.getAllProductCategory();
    taxDataSource = new TaxDataSource(dbHelper);
    taxDataSource.open(db);
    taxes = taxDataSource.getAllTax();
    unitDataSource = new UnitDataSource(dbHelper);
    unitDataSource.open(db);
    units = unitDataSource.getAllUnits();
    ingredientDatasource = new IngredientDataSource(dbHelper);
    ingredientDatasource.open(db);
    ingredientes = ingredientDatasource.getAllIngredient();
    productDatasource = new ProductDataSource(dbHelper);
    productDatasource.open(db);
    productos = productDatasource.getAllProduct();
    comboDatasource = new ComboDataSource(dbHelper);
    comboDatasource.open(db);
    combos = comboDatasource.getAllCombos();
    saleDataSource = new SaleDataSource(dbHelper);
    saleDataSource.open(db);
    saleList = saleDataSource.getAllSales();
    syncRowDataSource = new SyncRowDataSource(dbHelper);
    syncRowDataSource.open(db);

    Calendar today = Calendar.getInstance();
    Calendar tomorrow = Calendar.getInstance();
    today.set(Calendar.HOUR, 0);
    today.set(Calendar.HOUR_OF_DAY, 0);
    today.set(Calendar.MINUTE, 0);
    today.set(Calendar.SECOND, 0);
    today.set(Calendar.MILLISECOND, 0);
    tomorrow.roll(Calendar.DATE, 1);
    tomorrow.set(Calendar.HOUR, 0);
    tomorrow.set(Calendar.HOUR_OF_DAY, 0);
    tomorrow.set(Calendar.MINUTE, 0);
    tomorrow.set(Calendar.SECOND, 0);
    tomorrow.set(Calendar.MILLISECOND, 0);

    init = today.getTimeInMillis();
    end = tomorrow.getTimeInMillis();
    //Log.d(TAG, today.toString());
    //Log.d(TAG, tomorrow.toString());
    Calendar now = Calendar.getInstance();
    now.setTimeInMillis(System.currentTimeMillis());
    //Log.d(TAG, now.toString());

    //Log.d(TAG, "Diferencia entre tiempos: " + String.valueOf(end - init));
    salesFromToday = saleDataSource.getAllSalesWithin(init, end);
    updateRegistrables();
    // ingredientDatasource.close();
    mDemoCollectionPagerAdapter = new DemoCollectionPagerAdapter(getSupportFragmentManager());
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mDemoCollectionPagerAdapter);

    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between pages, select the
            // corresponding tab.
            getActionBar().setSelectedNavigationItem(position);

        }
    });

    final ActionBar actionBar = getActionBar();
    // Specify that tabs should be displayed in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create a tab listener that is called when the user changes tabs.
    ActionBar.TabListener tabListener = new ActionBar.TabListener() {

        @Override
        public void onTabReselected(Tab tab, FragmentTransaction ft) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onTabSelected(Tab tab, FragmentTransaction ft) {
            mViewPager.setCurrentItem(tab.getPosition());

        }

        @Override
        public void onTabUnselected(Tab tab, FragmentTransaction ft) {
            // TODO Auto-generated method stub

        }

    };

    Tab homeTab = actionBar.newTab().setText("Inicio").setTabListener(tabListener);
    Tab ordersTab = actionBar.newTab().setText("rdenes").setTabListener(tabListener);
    /*Tab dailyTab = actionBar.newTab().setText("Registros")
    .setTabListener(tabListener);
    Tab inventoryTab = actionBar.newTab().setText("Inventarios")
    .setTabListener(tabListener);*/
    Tab nest5ReadTab = actionBar.newTab().setText("Nest5").setTabListener(tabListener);
    actionBar.addTab(homeTab, true);
    actionBar.addTab(ordersTab, false);
    //actionBar.addTab(dailyTab, false);
    //actionBar.addTab(inventoryTab, false);
    actionBar.addTab(nest5ReadTab, false);

    currentOrder = new LinkedHashMap<Registrable, Integer>();
    inTableRegistrable = new ArrayList<Registrable>();
    savedOrders = new LinkedHashMap<String, LinkedHashMap<Registrable, Integer>>();
    cookingOrders = new LinkedList<LinkedHashMap<Registrable, Integer>>();
    //cookingOrdersMethods = new LinkedHashMap<LinkedHashMap<Registrable, Integer>, String>();
    cookingOrdersDelivery = new LinkedHashMap<LinkedHashMap<Registrable, Integer>, Integer>();
    cookingOrdersTogo = new LinkedHashMap<LinkedHashMap<Registrable, Integer>, Integer>();
    //cookingOrdersTip = new LinkedHashMap<LinkedHashMap<Registrable, Integer>, Integer>();
    //cookingOrdersDiscount = new LinkedHashMap<LinkedHashMap<Registrable, Integer>, Double>();
    cookingOrdersTimes = new LinkedHashMap<LinkedHashMap<Registrable, Integer>, Long>();
    cookingOrdersTable = new LinkedHashMap<LinkedHashMap<Registrable, Integer>, CurrentTable<Table, Integer>>();
    openTables = new LinkedList<CurrentTable<Table, Integer>>();
    //cookingOrdersReceived = new LinkedHashMap<LinkedHashMap<Registrable, Integer>, Double>();
    frases = getResources().getStringArray(R.array.phrases);
    timer = new Timer();
    deviceID = DeviceID.getDeviceId(mContext);
    //////Log.i("AACCCAAAID",deviceID);
    BebasFont = Typeface.createFromAsset(getAssets(), "fonts/BebasNeue.otf");
    VarelaFont = Typeface.createFromAsset(getAssets(), "fonts/Varela-Regular.otf");
    // Lector de tarjetas magnticas
    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    //mReader = new ACR31Reader(mAudioManager);
    /* Initialize the reset progress dialog */

    mResetProgressDialog = new ProgressDialog(mContext);

    // ACR31 RESET CALLBACK
    /*mReader.setOnResetCompleteListener(new ACR31Reader.OnResetCompleteListener() {
            
               
       //hola como estas
       @Override
       public void onResetComplete(ACR31Reader reader) {
            
    if (mSettingSleepTimeout) {
            
            
       mGettingStatus = true;
            
            
       mReader.setSleepTimeout(mSleepTimeout);
       mSettingSleepTimeout = false;
    }
            
    runOnUiThread(new Runnable() {
            
       @Override
       public void run() {
          mResetProgressDialog.dismiss();
       };
    });
       }
    });*/
    /* Set the raw data callback. */
    /*mReader.setOnRawDataAvailableListener(new ACR31Reader.OnRawDataAvailableListener() {
            
       @Override
       public void onRawDataAvailable(ACR31Reader reader, byte[] rawData) {
    ////Log.i("MISPRUEBAS", "setOnRawDataAvailableListener");
            
    final String hexString = toHexString(rawData)
          + (reader.verifyData(rawData) ? " (Checksum OK)"
                : " (Checksum Error)");
            
    ////Log.i("MISPRUEBAS", hexString);
    if (reader.verifyData(rawData)) {
       runOnUiThread(new Runnable() {
            
          @Override
          public void run() {
            
             mResetProgressDialog
                   .setMessage("Solicitando Informacin al Servidor...");
             mResetProgressDialog.setCancelable(false);
             mResetProgressDialog.setIndeterminate(true);
             mResetProgressDialog.show();
            
          }
       });
       SharedPreferences prefs = Util
             .getSharedPreferences(mContext);
            
       restService = new RestService(recievePromoandUserHandler,
             mContext, Setup.PROD_URL
                   + "/company/initMagneticStamp");
       restService.addParam("company",
             prefs.getString(Setup.COMPANY_ID, "0"));
       restService.addParam("magnetic5", hexString);
       restService.setCredentials("apiadmin", Setup.apiKey);
       try {
          restService.execute(RestService.POST);
       } catch (Exception e) {
          e.printStackTrace();
          ////Log.i("MISPRUEBAS", "Error empezando request");
       }
    }
            
       }
    });*/

}

From source file:it.polimi.deib.p2pchat.discovery.chatmessages.waitingtosend.discovery.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //FIXME TODO TODO FIXME
    //this is a temporary quick fix for Android N developer preview
    //use the strict mode with permit all is absolutely a bad practice,
    //but at the moment there is an open issue (not fixed) reported to google.
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);//www  .  j  a  va 2  s .c o  m
    //-----------------------------------------

    setContentView(R.layout.main);

    //activate the wakelock
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    this.setupToolBar();

    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);

    tabFragment = TabFragment.newInstance();

    this.getSupportFragmentManager().beginTransaction().replace(R.id.container_root, tabFragment, "tabfragment")
            .commit();

    this.getSupportFragmentManager().executePendingTransactions();
}