<activity android:configChanges="orientation|keyboardHidden"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:screenOrientation="portrait" android:name="com.wiwigo.app.SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.settings.WIFI_SETTINGS" />
<action android:name="android.net.wifi.PICK_WIFI_NETWORK" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.VOICE_LAUNCH" />
<category android:name="com.android.settings.SHORTCUT" />
</intent-filter>
</activity>
Android系统自身不检查应用程序的版本信息,也不会强制限制升级或兼容等。相反的,只是用户或应用程序自身对应用程序的版本有限制。
Android系统会对程序manifest中描述的系统版本(minSdkVersion特性指定)进行检查。这样,应用程序可以指定兼容的最低系统API等级。
为了定义应用程序的版本信息,你需要在程序的manifest文件中进行设定。这里有两个特性,而且往往你需要同时设定这两个值:
整数值有利于其它程序比较,检查是升级还是降级。你可以把这个值设定为任何想设的值,但是,你必须保证后续更新版的值要比这个大。系统不会强制要求这一行为,但是随着版本更新值也增加是正常的行为。
一般来说,你发布的第一版程序的versionCode设定为1,然后每次发布都会相应增加,不管发布的内容是较大还是较小的。这意味着android:versionCode不像应用程序的发布版本(看下面的android:versionName)那样显示给用户。应用程序和发布的服务不应该显示这个版本值给用户。
与android:versionCode一样,系统不会为了任何内部的目的使用这个值,除了显示给用户外。发布的服务也需要提取这个值来显示给用户。
你需要在manifest文件中定义这两个版本特性。
下面是一个manifest的例子,展示了android:versionCode和android:versionName特性的定义。
在这个例子中,android:versionCode的值显示当前apk是第二版释放的代码,而android:codeName字符串中表述了相应的小版本号。
Android框架提供了一个API来查询应用程序的版本信息。为了获取版本信息,应用程序可以使用PackageManager的getPackageInfo(java.lang.String, int)方法,例如:
appVersion 就是从配置文件取出的版本名,versionCode同理
如果你的程序有最低的Android平台限制,或者只是设计用于特定范围的Android平台,那么,你就可以在应用程序的manifest文件中指定API等级的信息。这样做是为了确保应用程序只能安装到搭载有兼容的Android系统的设备上。
指定API等级限制,在manifest文件中<uses-sdk>元素,并附带一个或多个特性:
当准备安装应用程序时,系统会检查这个属性的值并与系统的版本进行比较。如果android:minSdkVersion的值大于系统的版本,系统会放弃当前程序的安装。相似的,系统也只在android:maxSdkVersion与系统的版本兼容时才执行安装。
如果你没有在manifest中指定这些特性,那么,系统会假设你的程序与所有平台的版本兼容,且没有最高的API等级限制。
package httpclient;
import java.io.IOException;
import java.net.URLEncoder;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
public class HttpClientTest {
public static void main(String[] args) throws Exception{
String url = "/webservices/DomesticAirline.asmx/getDomesticAirlinesTime";
String host = "www.webxml.com.cn";
String param = "startCity="+URLEncoder.encode("杭州", "utf-8")+"&lastCity=&theDate=&userID=";
HttpClient httpClient = new HttpClient();
httpClient.getHostConfiguration().setHost(host, 80, "http");
HttpMethod method = getMethod(url, param);
//HttpMethod method = postMethod(url);
httpClient.executeMethod(method);
String response = method.getResponseBodyAsString();
//String response = new String(method.getResponseBodyAsString().getBytes("ISO-8859-1"));
System.out.println(response);
}
private static HttpMethod getMethod(String url,String param) throws IOException{
GetMethod get = new GetMethod(url+"?"+param);
get.releaseConnection();
return get;
}
private static HttpMethod postMethod(String url) throws IOException{
PostMethod post = new PostMethod(url);
post.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=gbk");
NameValuePair[] param = { new NameValuePair("startCity","杭州"),
new NameValuePair("lastCity","沈阳"),
new NameValuePair("userID",""),
new NameValuePair("theDate","") } ;
post.setRequestBody(param);
post.releaseConnection();
return post;
}
}