windows android studio 下载地址
2017-3-12 android
developer.android.com需要翻墙才能访问!
最近google下载软件地址好像放开了!
windows 版本 android studio下载地址如下:
https://dl.google.com/dl/android/studio/install/2.3.0.8/android-studio-ide-162.3764568-windows.exe
PHP实现soap null wsdl服务端,android 实现android client访问
2017-3-11 android
利用php实现soap的服务端供app等客户端访问
服务端:
新建php文件testServer.php
<?php
class service
{
public function HelloWorld()
{
return "hello";
}
}
$s = new SoapServer(null, array('uri' => 'test'));
$s->setClass("service");
$s->handle();
?>
客户端:
PHP调用:
import urllib2
SM_TEMPLATE = """<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
</soap:Header>
<soap:Body>
<HelloWorld>
</HelloWorld>
</soap:Body>
</soap:Envelope>"""
url = "http://www.qs77.net/testServer.php"
http_headers = {
"Accept": "application/soap+xml,multipart/related,text/*",
"Cache-Control":"no-cache",
"Content-Type": "text/xml; charset=utf-8"
}
request = urllib2.Request(url, SM_TEMPLATE, http_headers)
response = urllib2.urlopen(request)
print response.read()
android调用:
new Thread(new Runnable() {
@Override public void run() {
try {
final String soaptemp = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n" + " <soap:Header>" + " </soap:Header>" + " <soap:Body>" + " <HelloWorld>" + " </HelloWorld>" + " </soap:Body>" + "</soap:Envelope>";
URL url = new URL("http://www.qs77.net/testService.php"); HttpURLConnection urlCon = (HttpURLConnection) url.openConnection(); urlCon.setUseCaches(false); urlCon.setRequestProperty("Accept", "application/soap+xml,multipart/related,text/*"); urlCon.setRequestProperty("Content-Type", "text/xml; charset=utf-8"); urlCon.setRequestProperty("Content-Length", "" + soaptemp.getBytes().length); urlCon.setRequestProperty("soapAction", "HelloWorld"); urlCon.setRequestMethod("POST"); urlCon.setDoOutput(true); urlCon.setDoInput(true); OutputStream out = urlCon.getOutputStream(); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out, "UTF-8")); writer.write(soaptemp); writer.flush(); writer.close();
int status = urlCon.getResponseCode(); WolfLog.e(TAG, "" + status); InputStream in = null; if (status == 200) { in = urlCon.getInputStream(); } else { in = urlCon.getErrorStream(); } BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); String inputLine; StringBuilder input = new StringBuilder();
while ((inputLine = reader.readLine()) != null) { input.append(inputLine); } Document document = DocumentHelper.parseText(input.toString()); Element elementRoot = document.getRootElement(); Iterator<Element> iter = elementRoot.elementIterator();
while (iter.hasNext()) {
Element element = (Element)iter.next();
if ("Body".equals(element.getName())) { Iterator<Element> innerIter = element.elementIterator();
while (innerIter.hasNext()) { Element innerElement = (Element)innerIter.next(); WolfLog.e(TAG, innerElement.getName());
if ("HelloWorldResponse".equals(innerElement.getName())) { Iterator<Element> iinnerIter = innerElement.elementIterator();
while(iinnerIter.hasNext()) {
Element iinnerElement = (Element) iinnerIter.next();
if ("return".equals(iinnerElement.getName())) { Message msg = mHandler.obtainMessage(); Bundle bundle = new Bundle(); bundle.putString("msg", iinnerElement.getText()); msg.setData(bundle);
mHandler.sendMessage(msg);
}
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
标签: android python soap php dom4j
华为荣耀获取root权限后remount rw还是提示not permitted
2017-2-9 android
adb shellsu root
mount -o rw,remount /system
cd system
chattr -R -i * (回车)(关键步骤,没有这一步对底下的文件进行操作还是会提示not permitted)
标签: android adb remount not permitted
android 开启wifi热点api
2016-3-13 android
android默认开启wifi热点方式只能通过设置-移动网络共享-便携式wlan热点,为了开启一个热点要进行3部操作,实属麻烦!
因此通过网上查资料,实现wifi热点的一键启动!
通过google获知,android把wifi相关的api给隐藏了,因此只能通过反射机制进行调用!
/**
* Start AccessPoint mode with the specified
* configuration. If the radio is already running in
* AP mode, update the new configuration
* Note that starting in access point mode disables station
* mode operation
* @param wifiConfig SSID, security and channel details as
* part of WifiConfiguration
* @return {@code true} if the operation succeeds, {@code false} otherwise
*
* @hide Dont open up yet
*/
public boolean setWifiApEnabled(WifiConfiguration wifiConfig, boolean enabled) {
try {
mService.setWifiApEnabled(wifiConfig, enabled);
return true;
} catch (RemoteException e) {
return false;
}
}
配置AP的选项是属于wifi管理的一部分!获取当前系统wifi实例的方式如下:
WifiManger manager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
获取当前ap状态的方式如下:
public Boolean getApState() {
Boolean bApState = FALSE;
try {
Method method = manager.getClass().getMethod("isWifiApEnabled");
bApState = (Boolean)method.invoke(manager);
} catch (Exception e) {
e.printStackTrace();
bApState = FALSE;
}
return bApState;
}
配置ap使用的类为:WifiConfiguration //本例直接采用默认配置好的
public WifiConfiguration getApConfiguration() {
WifiConfiguration apConfigure = new WifiConfiguretion();
return apConfigure;
}
使能ap方式如下:public void setWifiAp(Boolean bOpen) {
if (bOpen) {
if (getApState()) {
return;
}
manager.setWifiEnabled(false);
}
try {
Method method = manager.getClass().getMethod("setWifiApEnabled", WifiConfiguration.class, Boolean.TYPE);
method.invoke(manager, getApConfiguration()/*采用默认的配置,则置为null*/, bOpen);
} catch (Exception e) {
e.printStackTrance();
}
}
源码已上传到github:https://github.com/aqi/WifiAssistant