1. 将Activity设置为对话框模式
例如:
<activity android:name=".DeviceListActivity"                  android:theme="@android:style/Theme.Dialog"                  android:configChanges="orientation|keyboardHidden" />


2. 设置Activity的进度条
protected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);setContentView(R.layout.loading);}setProgressBarIndeterminateVisibility(true);   //打开setProgressBarIndeterminateVisibility(false);  //关闭


3. Activity之间传递数据
//第一个activity,发送Intent i = new Intent();i.setClass(LoadingActivity.this, DetailsInfo.class);Bundle bundle = new Bundle(); bundle.putString("xml", strXML);//xml数据作为参数,传递给另一个activityi.putExtras(bundle);startActivity(i);//第二个activity,接收public void onCreate(Bundle savedInstanceState){        super.onCreate(savedInstanceState);                Bundle bunde = this.getIntent().getExtras();        String strXML = bunde.getString("xml"); }


4. int String 之间的转换
  // String转换为int    int i = Integer.parseInt([String]); 或      i = Integer.parseInt([String],[int radix]);     int i = Integer.valueOf(my_str).intValue();     // int转换为String    String s = String.valueOf(i);     String s = Integer.toString(i);      String s = "" + i; 


5. HttpURLConnection连接超时设置
URL url = null;HttpURLConnection urlConn = null;url = new URL(AppConstant.URL.Url_AgtTotalInfo);urlConn = (HttpURLConnection) url.openConnection();urlConn.setConnectTimeout(10 * 1000);System.out.println("time out is 10 seconds");try{if (urlConn.getResponseCode() != 200){throw new SocketTimeoutException("request url failed!");}}catch(SocketTimeoutException e){System.out.println(e);//System.out.println("not connected");urlConn.disconnect();}

更多相关文章

  1. android中的bundle传送数据
  2. Android Room联合AsyncListUtil实现RecyclerView分页加载ORM数据
  3. 重写对话框
  4. Android中Dialog对话框
  5. Android——SQLite数据库
  6. Android使用JDBC连接mysql数据库
  7. Android 高效的SQLite型数据库greenDAO使用

随机推荐

  1. android选择和裁剪图像拍摄的图像
  2. Android Animation 动画解析
  3. Android 多媒体应用——MediaPlayer与Sur
  4. Android 如何有效修改包名
  5. android studio 编译打包包含jni的sdk需
  6. Android(安卓)HIDL lshal
  7. Android(安卓)Gallery组件详解
  8. Android 屏幕刷新机制:ViewRootImpl、Chor
  9. 解决onConfigurationChanged不被调用
  10. Android DataBinding & MVVM