当前位置:  建站其它 iis7站长之家
本页文章导读:
    ▪获取手机的相干参数        获取手机的相关参数 package com.propviewer; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import android.app.Activity; import android.app.ActivityManager; import andro.........
    ▪ 兑现键盘弹出后视图跟随键盘一起上下移动        实现键盘弹出后视图跟随键盘一起上下移动 在.h中实现代码: @interface ShowTextfieldUnderKeyboardViewController : UIViewController <UITextViewDelegate>{ IBOutlet UITextView *myTextView; IBOutlet UIScrollView *myScrollView; .........
    ▪ 多抚摸获取方法       多触摸获取方法   - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{     //  messageLabel.text =@"Touches Began";   //    [self updateLabelsFromTouches:touches];           NSUInteger numTouches = [touches count];   .........

[1]获取手机的相干参数
    来源: 互联网  发布时间: 2014-02-18
获取手机的相关参数
package com.propviewer;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.os.Bundle;
import android.os.Environment;
import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.widget.TextView;

public class MainActivity extends Activity {
	private StringBuffer info = new StringBuffer();

	FileOutputStream fos = null;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		TextView tv = (TextView) findViewById(R.id.text);

		String ss = Environment.getExternalStorageDirectory().toString();

		File f = new File(ss + "/phonemsg.txt");
		if (!f.exists()) {
			try {
				f.createNewFile();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		

		// android.os.Build
		info.append("android.os.Build.MODEL:" + android.os.Build.MODEL + "\n");
		info.append("android.os.Build.VERSION.SDK:"
				+ android.os.Build.VERSION.SDK + "\n");
		info.append("android.os.Build.VERSION.RELEASE:"
				+ android.os.Build.VERSION.RELEASE + "\n");
		info.append("android.os.Build.BRAND:" + android.os.Build.BRAND + "\n");
		info
				.append("android.os.Build.DEVICE:" + android.os.Build.DEVICE
						+ "\n");

		// Log.v("test","android.os.Build.MODEL:"
		// + android.os.Build.MODEL + "\n");

		try {
			fos = new FileOutputStream(f);
			try {
				
				fos
						.write(("android.os.Build.MODEL:"
								+ android.os.Build.MODEL + "\n").getBytes());
				fos.write(("android.os.Build.VERSION.SDK:"
						+ android.os.Build.VERSION.SDK + "\n").getBytes());
				fos.write(("android.os.Build.VERSION.RELEASE:"
						+ android.os.Build.VERSION.RELEASE + "\n").getBytes());
				fos
						.write(("android.os.Build.BRAND:"
								+ android.os.Build.BRAND + "\n").getBytes());
				fos
						.write(("android.os.Build.DEVICE:"
								+ android.os.Build.DEVICE + "\n").getBytes());
				
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}

		// Screen Metric INFO
		ShowScreenMetricInfo();

		// TELEPHONE
		info.append("\nTELEPHONE INFO\n");
		TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
		info.append("DEVICE ID(MEID/IMEI):" + tm.getDeviceId() + "\n");
		info.append("Subscriber ID:").append(tm.getSubscriberId()).append("\n");
		info.append("DEVICE Software Version:" + tm.getDeviceSoftwareVersion()
				+ "\n");
		info.append("Line1 Number:" + tm.getLine1Number() + "\n");
		info.append("Network Country ISO:" + tm.getNetworkCountryIso() + "\n");
		info.append("Network Operator:" + tm.getNetworkOperator() + "\n");
		info.append("Network Operator Name:" + tm.getNetworkOperatorName()
				+ "\n");
		//
		info.append("Network Type:");
		info.append(getNetworkTypeStr(tm.getNetworkType()));
		info.append("\n");
		//
		info.append("Phone Type:");
		info.append(getPhoneTypeStr(tm.getPhoneType()));
		info.append("\n");

		// System.getProperty
		info.append("\nSystem.getProperty\n");
		
		for (int i = 0; i < SYS_PROP.length; ++i) {
			String pn = SYS_PROP[i];
			info.append(pn + ":" + System.getProperty(pn) + "\n");
		}
		info.append("\nMEMORY USAGE" + "\n");
		
		try {
			fos.write(("\nTELEPHONE INFO\n").getBytes());
			fos.write(("DEVICE ID(MEID/IMEI):" + tm.getDeviceId() + "\n")
					.getBytes());
			fos
			.write((("Subscriber ID:") + (tm.getSubscriberId()) + ("\n"))
					.getBytes());
			fos.write((("DEVICE Software Version:"
					+ tm.getDeviceSoftwareVersion() + "\n")).getBytes());
			fos.write(("Line1 Number:" + tm.getLine1Number() + "\n")
					.getBytes());
			fos
			.write((("Network Country ISO:"
					+ tm.getNetworkCountryIso() + "\n").getBytes()));
			

			fos
			.write((("Network Operator:" + tm.getNetworkOperator() + "\n"))
					.getBytes());
			

			
			fos
			.write((("Network Type:")
					+ getPhoneTypeStr(tm.getPhoneType()) + "\n")
					.getBytes());
			fos
			.write((("Phone Type:")
					+ getPhoneTypeStr(tm.getPhoneType()) + "\n")
					.getBytes());
			fos.write("\nSystem.getProperty\n".getBytes());
			for (int i = 0; i < SYS_PROP.length; ++i) {
				String pn = SYS_PROP[i];
				fos.write((pn + ":" + System.getProperty(pn) + "\n")
						.getBytes());
			}
			fos.write(("\nMEMORY USAGE" + "\n").getBytes());
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
//		TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);



		// Memory Usage
	
		ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
		ActivityManager.MemoryInfo mf = new ActivityManager.MemoryInfo();
		am.getMemoryInfo(mf);
		info.append("剩余内存: ").append(mf.availMem >> 10).append("K\n");
		;
		info.append("剩余内存: ").append(mf.availMem >> 20).append("M\n");
		;
		info.append("是否处于低内存状态:").append(mf.lowMemory);

		info.append("" + "\n");
		info.append("" + "\n");

		try {
			fos.write((("剩余内存: ") + (mf.availMem >> 10) + ("K\n")).getBytes());
			fos.write((("剩余内存: ") + (mf.availMem >> 20) + ("M\n")).getBytes());
			fos.write((("是否处于低内存状态:") + (mf.lowMemory)).getBytes());
			fos.write(("" + "\n").getBytes());
			fos.write(("" + "\n").getBytes());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		tv.setText(info.toString());
	}

	public void ShowScreenMetricInfo() {
		// Screen Metric INFO
		DisplayMetrics dm = this.getApplicationContext().getResources()
				.getDisplayMetrics();
		info.append("\nScreen Metric INFO" + "\n");
		info.append("The absolute width of the display in pixels: ").append(
				dm.widthPixels).append("\n");
		info.append("The absolute height of the display in pixels: ").append(
				dm.heightPixels).append("\n");
		info.append("The logical density of the display.: ").append(dm.xdpi)
				.append("\n");
		info
				.append(
						"The exact physical pixels per inch of the screen in the Y dimension:")
				.append(dm.ydpi).append("\n");
		info.append("The screen density expressed as dots-per-inch:").append(
				dm.density).append("\n");
		info
				.append(
						"The exact physical pixels per inch of the screen in the X dimension:")
				.append(dm.densityDpi).append("\n");
		info.append("A scaling factor for fonts displayed on the display:")
				.append(dm.scaledDensity).append("\n");

		try {
			fos.write(("\nScreen Metric INFO" + "\n").getBytes());
			fos.write((("The absolute width of the display in pixels: ")
					+ dm.widthPixels + "\n").getBytes());
			fos.write((("The absolute height of the display in pixels: ")
					+ dm.heightPixels + "\n").getBytes());
			fos
					.write((("The logical density of the display.: ") + dm.xdpi + "\n")
							.getBytes());
			fos
					.write((("The exact physical pixels per inch of the screen in the Y dimension:")
							+ dm.ydpi + "\n").getBytes());
			fos.write((("The screen density expressed as dots-per-inch:")
					+ dm.density + "\n").getBytes());
			fos
					.write((("The exact physical pixels per inch of the screen in the X dimension:")
							+ dm.densityDpi + "\n").getBytes());
			fos.write((("A scaling factor for fonts displayed on the display:")
					+ dm.scaledDensity + "\n").getBytes());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public static String getPhoneTypeStr(int type) {
		switch (type) {
		case TelephonyManager.PHONE_TYPE_NONE:
			return "PHONE_TYPE_NONE";
		case TelephonyManager.PHONE_TYPE_GSM:
			return "PHONE_TYPE_GSM";
		case TelephonyManager.PHONE_TYPE_CDMA:
			return "PHONE_TYPE_CDMA";
		default:
			return "unknow phone type:[" + type + "]";
		}
	}

	public static String getNetworkTypeStr(int type) {
		switch (type) {
		case TelephonyManager.NETWORK_TYPE_UNKNOWN:
			return "NETWORK_TYPE_UNKNOWN";
		case TelephonyManager.NETWORK_TYPE_GPRS:
			return "NETWORK_TYPE_GPRS";
		case TelephonyManager.NETWORK_TYPE_EDGE:
			return "NETWORK_TYPE_EDGE";
		case TelephonyManager.NETWORK_TYPE_UMTS:
			return "NETWORK_TYPE_UMTS";
		case TelephonyManager.NETWORK_TYPE_HSDPA:
			return "NETWORK_TYPE_HSDPA";
		case TelephonyManager.NETWORK_TYPE_HSUPA:
			return "NETWORK_TYPE_HSUPA";
		case TelephonyManager.NETWORK_TYPE_HSPA:
			return "NETWORK_TYPE_HSPA";
		case TelephonyManager.NETWORK_TYPE_CDMA:
			return "NETWORK_TYPE_CDMA";
		case TelephonyManager.NETWORK_TYPE_EVDO_0:
			return "NETWORK_TYPE_EVDO_0";
		case TelephonyManager.NETWORK_TYPE_EVDO_A:
			return "NETWORK_TYPE_EVDO_A";
		case TelephonyManager.NETWORK_TYPE_1xRTT:
			return "NETWORK_TYPE_1xRTT";
		default:
			return "unknow network type:[" + type + "]";
		}
	}

	public static final String[] SYS_PROP = { "os.name", "os.version",
			"os.arch", "user.name", "user.home", "user.dir", "user.timezone",
			"java.home", "java.version", "java.class.version", "java.vendor",
			"java.vendor.url", "java.class.path", "path.separator",
			"line.separator", "file.separator", };
}// END OF CLASS MainActivity


 

获取手机的参数,展示,并保存到sdcard中的代码。

 

 


    
[2] 兑现键盘弹出后视图跟随键盘一起上下移动
    来源: 互联网  发布时间: 2014-02-18
实现键盘弹出后视图跟随键盘一起上下移动

在.h中实现代码:

@interface ShowTextfieldUnderKeyboardViewController : UIViewController <UITextViewDelegate>{

IBOutlet UITextView *myTextView;
IBOutlet UIScrollView *myScrollView;
}

@property(nonatomic,retain) UITextView *myTextView;
@property(nonatomic,retain) UIScrollView *myScrollView;
-(IBAction)Click;
@end

注意添加<UITextViewDelegate>协议。

在.m中实现代码:

#import “ShowTextfieldUnderKeyboardViewController.h”

@implementation ShowTextfieldUnderKeyboardViewController
@synthesize myTextView,myScrollView;

- (void)viewDidLoad {
[self.myScrollView setFrame:CGRectMake(0, 0, 320, 480)];
[myScrollView setContentSize:CGSizeMake(320, 481)];
myTextView.text = @”Please input:”;
myTextView.delegate = self;
}

-(void)Click{
[myTextView resignFirstResponder];
}

-(void)textViewDidBeginEditing:(UITextView *)textView
{
[UIView beginAnimations:@"showKeyboardAnimation" context:nil];
[UIView setAnimationDuration:0.30];
self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y- 100, self.view.frame.size.width, self.view.frame.size.height);
[UIView commitAnimations];
}
- (void)textViewDidChange:(UITextView *)textView{

}
- (void)textViewDidEndEditing:(UITextView *)textView{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.30];
CGRect rect = self.view.frame;
rect.origin.y += 100;
self.view.frame = rect;
[UIView commitAnimations];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}

- (void)viewDidUnload {
}

- (void)dealloc {
[myTextView release];
[super dealloc];
}
@end


    
[3] 多抚摸获取方法
    来源: 互联网  发布时间: 2014-02-18
多触摸获取方法

 

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

 

  //  messageLabel.text =@"Touches Began";

 

//    [self updateLabelsFromTouches:touches];

 

 

      NSUInteger numTouches = [touches count];

 

      NSUInteger numTags = [[touches anyObject] tapCount];

 

}

 

numTags 获取轻击次数 . 

touches 的个数表示当前按压屏幕的手指数量.

 

 


    
最新技术文章:
▪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