当前位置: 编程技术>移动开发
本页文章导读:
▪掩藏的数字咪咪 隐藏的数字咪咪
Android Phone Information Secret Code: *#*#4636#*#*
To get the information of your phone and battery. including Phone information, Battery information, Battery history, and Usage statistics.
Android Phone Reset Secret Code: *#*.........
▪ Socket传递文件 Socket传送文件
客户端:
Client.java
package lee.socket;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
impo.........
▪ ListView中动态刷新数据的另类步骤 ListView中动态刷新数据的另类方法
前阵子有个需求,一个显示视频的listview,每个item中包含点播次数,点击一次立即加1,并动态显示在界面上。看了好多资料,拜读了很多帖子,也试了很多.........
[1]掩藏的数字咪咪
来源: 互联网 发布时间: 2014-02-18
隐藏的数字咪咪
Android Phone Information Secret Code: *#*#4636#*#* To get the information of your phone and battery. including Phone information, Battery information, Battery history, and Usage statistics. Android Phone Reset Secret Code: *#*#7780#*#* To reset your Android phone back to factory data. It will delete the things including Google account settings stored in your phone, System and application data and settings, and Downloaded applications too. I wont delete, including current system software, bundled applications, SD card files e.g. photos, music files. Android Phone Factory Format Secret Code: *2767*3855# It is used for factory format, which will delete all files and settings, including the internal memory storage. It will also reinstall the firmware. Android Phone Camera Information Secret Code: *#*#34971539#*#* It is used to get information about the camera. It includes following 4 menus: Update camera firmware in image, Update camera firmware in SD card, Get camera firmware version, and Get firmware update count. You should never use the first option otherwise your phone camera may stop working, and there is really no reason to update the camera firmware anyway. Android Phone Secret Code: *#*#7594#*#* It will change the "End Call / Power" button action on your phone. By default, if you long press the button, it shows a screen asking you to select any option from Silent mode, Airplane mode and Power off. You can change this action using this code. You can enable direct power off on this button so you don't need to waste your time in selecting the option. Android Phone Backup Secret Code: *#*#273283*255*663282*#*#* It opens a File copy screen where you can backup your media files e.g. Images, Sound, Video and Voice memo. Android Phone Service mode Secret Code: *#*#197328640#*#* It can be used to enter into Service mode. You can run various tests and change settings in the service mode. Android Phone WLAN, GPS and Bluetooth Test Secret Codes: *#*#232339#*#* OR *#*#526#*#* OR *#*#528#*#* ¨C WLAN test (Use "Menu" button to start various tests) *#*#232338#*#* ¨C Shows WiFi MAC address *#*#1472365#*#* ¨C GPS test *#*#1575#*#* ¨C Another GPS test *#*#232331#*#* ¨C Bluetooth test *#*#232337#*# ¨C Shows Bluetooth device address Android Phone GTalk Secret Codes: *#*#8255#*#* It can be used to launch GTalk Service Monitor. Android Phone Firmware version information Secret Codes: *#*#4986*2650468#*#* ¨C PDA, Phone, H/W, RFCallDate *#*#1234#*#* ¨C PDA and Phone *#*#1111#*#* ¨C FTA SW Version *#*#2222#*#* ¨C FTA HW Version *#*#44336#*#* - PDA, Phone, CSC, Build Time, Changelist number Android Phone Factory Tests Secret Codes: *#*#0283#*#* ¨C Packet Loopback *#*#0*#*#* ¨C LCD test *#*#0673#*#* OR *#*#0289#*#* ¨C Melody test *#*#0842#*#* ¨C Device test (Vibration test and BackLight test) *#*#2663#*#* ¨C Touch screen version *#*#2664#*#* ¨C Touch screen test *#*#0588#*#* ¨C Proximity sensor test *#*#3264#*#* ¨C RAM version
[2] Socket传递文件
来源: 互联网 发布时间: 2014-02-18
Socket传送文件
客户端:
Client.java
package lee.socket; import java.io.BufferedInputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.net.Socket; public class Client { static DataInputStream din = null; static DataOutputStream dout = null; static Socket s = null; public static void main(String[] args) { try { s = new Socket("127.0.0.1", 2224); File file = new File("d:/05.jpg"); // 定义文件 FileInputStream fis = new FileInputStream(file); // 定义文件输入流 din = new DataInputStream(new BufferedInputStream(fis)); // 用缓存流包装文件输入流(提高读取速度),然后再包装成数据输入流 dout = new DataOutputStream(s.getOutputStream());// 定义数据输出流 dout.writeUTF(String.valueOf(file.length())); // 发送文件长度 byte[] buffer = new byte[1024]; // 定义缓存 int len = 0; while ((len = din.read(buffer)) != -1) { dout.write(buffer, 0, len); // 向服务器发送数据 } dout.flush(); } catch (IOException e) { System.out.println(e.toString()); } finally { try { if (din != null) { din.close(); din = null; } } catch (Exception e) { e.printStackTrace(); } try { if (dout != null) { // 最后一定要关闭输出流,不然数据发送不出去。导致一直连接着,不断开 dout.close(); dout = null; } } catch (Exception e) { e.printStackTrace(); } try { if (s != null) { s.close(); s = null; } } catch (Exception e) { e.printStackTrace(); } } } }
Android和客户端基本一样。
服务端:
Server.java
package lee.socket; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; public class Server { static DataInputStream din = null; static DataOutputStream dout = null; static Socket s = null; public static void main(String[] args) { new Thread() { // 开启子线程 public void run() { try { ServerSocket ss = new ServerSocket(2224); // 这个必须在while外,不然会循环连接端口,出错 while (true) { System.out.println("--------等待用户连接--------------"); s = ss.accept(); System.out.println("--------用户连接上了--------------"); din = new DataInputStream(new BufferedInputStream(s .getInputStream()));// 使用缓存进行包装,提示读取速度 System.out.println("文件长度:" + din.readUTF()); // 显示接收文件长度 File file = new File("d:/01.jpg"); FileOutputStream fos = new FileOutputStream(file); dout = new DataOutputStream(new BufferedOutputStream( fos)); byte[] buffer = new byte[1024]; int len = 0; while ((len = din.read(buffer)) != -1) { dout.write(buffer, 0, len); } dout.flush(); dout.close(); // 下面的finally要等到循环结束后才执行,如果不执行close,文件无法正常打开 System.out.println("接受成功"); } } catch (IOException e) { e.printStackTrace(); } finally { // 等while循环结束后才会执行, try { if (dout != null) { dout.close(); dout = null; } } catch (Exception e) { e.printStackTrace(); } try { if (din != null) { din.close(); din = null; } } catch (Exception e) { e.printStackTrace(); } try { if (s != null) { s.close(); s = null; } } catch (Exception e) { e.printStackTrace(); } } } }.start(); } }
[3] ListView中动态刷新数据的另类步骤
来源: 互联网 发布时间: 2014-02-18
ListView中动态刷新数据的另类方法
前阵子有个需求,一个显示视频的listview,每个item中包含点播次数,点击一次立即加1,并动态显示在界面上。看了好多资料,拜读了很多帖子,也试了很多方法,用notifyDataSetChanged()都不行。看到优酷客户端(塞班系统的)也不能更新次数,本来都泄气了,结果被论坛里一个牛人说:“你很强,研究出来分享下”,硬着头皮上呗。但我觉得理论上肯定是可以实现的,经过艰苦卓绝的尝试,终于皇天不负有心人。现在和大家分享一下经验,相信一定对很多人的应用有用,也欢迎大家拍砖。
1.在点击item的监听程序onItemClick()中调用播放方法并加1,发送消息给handler更新次数
private void updatePalyNum(final int position) { new Thread() { public void run() { try { boolean updateFlag = videoWS.updateData(getString(R.string.WSURL_update),newsList.get(position).getVideoID()); if(updateFlag){ int playNum=Integer.parseInt(newsList.get(position).getPlayNum()); playNum++; newsList.get(position).setPlayNum(playNum+""); Uri uri = Uri.parse(newsList.get(position).getUrl()); Intent intent = new Intent(Intent.ACTION_VIEW,uri); intent.setType("video/*"); intent.setDataAndType(uri , "video/*"); startActivity(intent); Thread.sleep(400); handler.sendEmptyMessage(5); } }catch (InterruptedException e) { e.printStackTrace(); } } }.start(); }
2.handler处理刷新listview
case 5: listAdapter=null; listView.setAdapter(getAdapter(newsList)); break;
这个方法我不知道是不是正规,希望高手指点。另外还有一点问题就是每次重新加载都是在第一页,如果当时您不在第一页播放的话播放完回来就找不着北了,不过这个问题理论上也是可以解决的。
最新技术文章: