当前位置:  编程技术>移动开发
本页文章导读:
    ▪掩藏的数字咪咪        隐藏的数字咪咪 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;

 这个方法我不知道是不是正规,希望高手指点。另外还有一点问题就是每次重新加载都是在第一页,如果当时您不在第一页播放的话播放完回来就找不着北了,不过这个问题理论上也是可以解决的。


    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之自定义Menu(TabMenu)实现方法
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3