WEB开发网
开发学院手机开发Android 开发 Android 测试工具类 阅读

Android 测试工具类

 2010-02-09 03:51:00 来源:WEB开发网   
核心提示:这是Unlocking Android 这本书Sample的代码。直接上代码package com.msi.manning.telephonyexplorer;import android.app.Activity;import android.content.Context;import android.os.Bun

这是Unlocking Android 这本书Sample的代码。直接上代码

package com.msi.manning.telephonyexplorer;

import android.app.Activity;

import android.content.Context;

import android.os.Bundle;

import android.telephony.PhoneStateListener;

import android.telephony.TelephonyManager;

import android.telephony.gsm.GsmCellLocation;

import android.util.Log;

import android.widget.TextView;

public class TelephonyManagerExample extends Activity {

private TextView telMgrOutput;

@Override

public void onCreate(final Bundle icicle) {

Log.d(Constants.LOGTAG, "TelephonyManagerExample onCreate");

super.onCreate(icicle);

this.setContentView(R.layout.telmgrexample);

this.telMgrOutput = (TextView) this.findViewById(R.id.telmgroutput);

}

@Override

public void onStart() {

super.onStart();

// TelephonyManager

final TelephonyManager telMgr = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);

this.telMgrOutput.setText(telMgr.toString());

// PhoneStateListener

PhoneStateListener phoneStateListener = new PhoneStateListener() {

@Override

public void onCallStateChanged(final int state, final String incomingNumber) {

TelephonyManagerExample.this.telMgrOutput

.setText(TelephonyManagerExample.this.getTelephonyOverview(telMgr));

Log.d(Constants.LOGTAG, "phoneState updated - incoming number - " + incomingNumber);

}

};

telMgr.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);

String telephonyOverview = this.getTelephonyOverview(telMgr);

this.telMgrOutput.setText(telephonyOverview);

}

@Override

public void onPause() {

1 2 3  下一页

Tags:Android工具

编辑录入:coldstar [复制链接] [打 印]
赞助商链接