根據您的手機,您可以將您的Android手機設置爲便攜式熱點,並通過iPhone連接到該手機。從那裏它將是特定於應用程序的數據傳輸。
但是,您也可以使用Androids WiFi-Direct庫。在這種情況下,您將使用它們來設置Android手機以創建「羣組所有者」,這基本上與便攜式熱點相同。退房:
http://developer.android.com/guide/topics/connectivity/wifip2p.html
我會給你一個代碼示例,以幫助您開始。
public class WifiDirectAPtestActivity extends Activity
{
private WifiP2pManager manager;
private boolean isWifiP2pEnabled = false;
private boolean retryChannel = false;
private final IntentFilter intentFilter = new IntentFilter();
private Channel channel;
private BroadcastReceiver receiver = null;
public void setIsWifiP2pEnabled(boolean isWifiP2pEnabled) {
this.isWifiP2pEnabled = isWifiP2pEnabled;
}
@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);
}
/** register the BroadcastReceiver with the intent values to be matched */
@Override
public void onResume() {
super.onResume();
receiver = new WiFiDirectBroadcastReceiver(manager, channel, this);
registerReceiver(receiver, intentFilter);
createGroup();
}
@Override
public void onPause() {
super.onPause();
unregisterReceiver(receiver);
manager.removeGroup(channel, new ActionListener() {
@Override
public void onFailure(int reasonCode) {
Log.d("WifiDirectAptestActivity", "Disconnect failed. Reason :" + reasonCode);
}
@Override
public void onSuccess() {
Log.d("WifiDirectAptestActivity", "Should have been sucessfully removed");
}
});
}
public void createGroup()
{
manager.createGroup(channel, new ActionListener() {
@Override
public void onSuccess() {
// WiFiDirectBroadcastReceiver will notify us. Ignore for now.
Log.d("WifiDirectAPtestActivity", "Group creating request successfully send");
}
@Override
public void onFailure(int reason) {
Toast.makeText(WifiDirectAPtestActivity.this, "Connect failed. Retry.",
Toast.LENGTH_SHORT).show();
}
});
}
此外,您需要廣播接收器,看看WiFi-Direct演示,它應該很清楚。
注意,線manager.createGroup(信道,新的ActionListener()是感興趣的代碼行,在這條線實際上設置該設備作爲一個便攜式熱點。
希望這澄清的事情,我不噸真的知道你需要解釋如何詳細。評論,如果有些事情是不明確的。
馬麗娟思想....期待着答案...... –
我不認爲這是可能的,至少在沒有建立移動熱點 –
相關問題:http://stackoverflow.com/questions/9799804/is-wi-fi-direct-connection-possible-within-ios-devices-and-among-wifi-direct-ena – AlcubierreDrive