久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

[z]How to enable hotspot by api

 techres 2012-06-20

What is the API call I need to make in Android 2.2 (Froyo) to create a Wifi hotspot (as seen in the Tethering and Portable Hotspot settings item).

link|improve this question
I still can't believe there is no API for activating/deactivating tethering. Hope that it exists, but is just not documented yet. – Sney Jul 2 '10 at 13:04
feedback

2 Answers

You can call

public boolean setWifiApEnabled(WifiConfiguration wifiConfig, boolean enabled);

using reflection :)

after getting the WifiManager use the reflection to get the WifiManager declared methods, look for this method name setWifiApEnabled and invoke it through the WifiManager object

These API are marked as @hide, so currently you cannot use them directly, but they appear on the AIDL for the WifiManager so their are accessible!

An example can be:

WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
Method[] wmMethods = wifi.getClass().getDeclaredMethods();
for(Method method: wmMethods){
 
if(method.getName().equals("setWifiApEnabled")){
   
WifiConfiguration netConfig = new WifiConfiguration();
    netConfig
.SSID = "\"PROVAAP\"";
    netConfig
.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
    netConfig
.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
    netConfig
.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
    netConfig
.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);    netConfig.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
    netConfig
.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
    netConfig
.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
    netConfig
.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);  

   
try {
      method
.invoke(wifi, netConfig,true);
   
} catch (IllegalArgumentException e) {
      e
.printStackTrace();
   
} catch (IllegalAccessException e) {
      e
.printStackTrace();
   
} catch (InvocationTargetException e) {
      e
.printStackTrace();
   
}
 
}
}

It works but I cannot change the current configuration with my own, and getting the current WifiConfiguration of an active AP drive me to an empty configuration.Why?

link|improve this answer
good investigation – Schildmeijer Aug 2 '10 at 14:55
You can always access them through reflection! – Chris Thompson Aug 2 '10 at 14:56
@markov00: Your suggested approach is not part of the Android SDK. Do not use it, period. – CommonsWare Aug 26 '10 at 3:52
@CommonsWare, why not? It might not work in a future version of Android, I suppose, but if you're willing to take that risk, what's wrong with that? – MatrixFrog Aug 27 '10 at 20:06
2  
@MatrixFrog: Tactically, it may break on current devices. Device manufacturers are very willing to remove or alter this feature on behalf of carriers. Assuming that any non-SDK code will work, or even exist, is simply not reliable. If you want to use this code for some toy app you use on your own phone, be my guest. Only a fool will ship an application, though, that is designed to disappoint customers. Strategically, the more developers go past the SDK, the more difficult it is for me and others to convince manufacturers to not screw with stuff that's supposed to be supported in the SDK. – CommonsWare Aug 29 '10 at 7:41
show 5 more comments
feedback

There does not appear to be an API call to create a WiFi hotspot -- sorry!

link|improve this answer

    本站是提供個(gè)人知識管理的網(wǎng)絡(luò)存儲(chǔ)空間,,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn),。請注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購買等信息,,謹(jǐn)防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多