layout.addView(button);<br style="word-wrap:break-word;">
layout.removeView(button);<br style="word-wrap:break-word;">
138 android 刷新地图显示函数<br style="word-wrap:break-word;">
//继承MapActivity并重写以下方法<br style="word-wrap:break-word;">
public void refreshMapView()&nbsp;<br style="word-wrap:break-word;">
{}<br style="word-wrap:break-word;">
139 android 创建LocationManager<br style="word-wrap:break-word;">
LocationManager locationManager =&nbsp;<br style="word-wrap:break-word;">
(LocationManager)getSystemService(Context.LOCATION_SERVICE);<br style="word-wrap:break-word;">
140 android 设置webView的javascript有效<br style="word-wrap:break-word;">
WebView webView = new WebView(this);<br style="word-wrap:break-word;">
webView.setJavaScriptEnabled(true);<br style="word-wrap:break-word;">
141 android 设置webView的保存密码有效<br style="word-wrap:break-word;">
WebView webView = new WebView(this);<br style="word-wrap:break-word;">
webSettings.setSavePassword(true);<br style="word-wrap:break-word;">
142 android 获得PowerManager<br style="word-wrap:break-word;">
PowerManager powerManager = (PowerManager)getSystemService(Context.POWER_SERVICE);<br style="word-wrap:break-word;">
143 android 相机的预览<br style="word-wrap:break-word;">
parameters.setPreviewSize(640, 480);<br style="word-wrap:break-word;">
//参数的其他设定参考“设置相机图片大小和像素等”<br style="word-wrap:break-word;">
camera.setPreviewDisplay(surfaceHolder);<br style="word-wrap:break-word;">
//这里是个SurfaceHolder对象<br style="word-wrap:break-word;">
camera.startPreview();<br style="word-wrap:break-word;">
camera.stopPreview();<br style="word-wrap:break-word;">
144 android Google Map的移动<br style="word-wrap:break-word;">
GeoPoint point = new GeoPoint(xxx, yyy);<br style="word-wrap:break-word;">
MapController controller = mapView.getController();&nbsp;<br style="word-wrap:break-word;">
controller.animateTo(point);<br style="word-wrap:break-word;">
145 android 设置画笔粗细<br style="word-wrap:break-word;">
Paint paint= new Paint();<br style="word-wrap:break-word;">
paint.setStrokeWidth(1);<br style="word-wrap:break-word;">
146 android 打开相机<br style="word-wrap:break-word;">
Camera.open();<br style="word-wrap:break-word;">
147 android 设置相机图片大小和像素等<br style="word-wrap:break-word;">
Camera.Parameters parameters = camera.getParameters();<br style="word-wrap:break-word;">
//设置相片格式为JPEG<br style="word-wrap:break-word;">
parameters.setPictureFormat(PixelFormat.JPEG);<br style="word-wrap:break-word;">
//设置图片分辨率大小<br style="word-wrap:break-word;">
parameters.setPictureSize(640, 480);<br style="word-wrap:break-word;">
camera.setParameters(parameters);<br style="word-wrap:break-word;">
148 android 将屏幕亮着<br style="word-wrap:break-word;">
PowerManager.WakeLock wakeLock = mPowerManager.newWakeLock<br style="word-wrap:break-word;">
(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "BackLight");<br style="word-wrap:break-word;">
149 android 暂停和恢复activity<br style="word-wrap:break-word;">
protected void onPause()<br style="word-wrap:break-word;">
{<br style="word-wrap:break-word;">
&nbsp; &nbsp; super.onPause();<br style="word-wrap:break-word;">
}<br style="word-wrap:break-word;">
protected void onResume()&nbsp;<br style="word-wrap:break-word;">
{&nbsp;<br style="word-wrap:break-word;">
&nbsp; &nbsp; super.onResume();&nbsp;<br style="word-wrap:break-word;">
}<br style="word-wrap:break-word;">
150 android 保存和恢复canvas设置<br style="word-wrap:break-word;">
canvas.save();//保存设置<br style="word-wrap:break-word;">
//之间做一些变换,转移,拉伸等操作<br style="word-wrap:break-word;">
canvas.restore();//恢复设置<br style="word-wrap:break-word;">
151 android 地图搜索<br style="word-wrap:break-word;">
Intent search = new Intent(Intent.ACTION_WEB_SEARCH);<br style="word-wrap:break-word;">
search.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);<br style="word-wrap:break-word;">
search.putExtra(SearchManager.QUERY, "new york");<br style="word-wrap:break-word;">
startActivity(search);<br style="word-wrap:break-word;">
152 android 设置播放器音量<br style="word-wrap:break-word;">
mediaPlayer.setVolume(10, 10);<br style="word-wrap:break-word;">
153 android 播放器跳转到具体位置<br style="word-wrap:break-word;">
mediaPlayer.seekTo(0);//0的单位是毫秒<br style="word-wrap:break-word;">
154 android 获得手机号码和手机串号(IMEI)<br style="word-wrap:break-word;">
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);&nbsp;<br style="word-wrap:break-word;">
String imei = telephonyManager.getDeviceId();&nbsp;<br style="word-wrap:break-word;">
String tel = telephonyManager.getLine1Number();&nbsp;<br style="word-wrap:break-word;">
155 android 闹钟设置代码<br style="word-wrap:break-word;">
//接受闹铃并显示提示<br style="word-wrap:break-word;">
class AlarmReceiver extends BroadcastReceiver {&nbsp;<br style="word-wrap:break-word;">
public void onReceive(Context context, Intent intent) {&nbsp;<br style="word-wrap:break-word;">
Toast.makeText(context, "时间到", Toast.LENGTH_LONG).show();&nbsp;<br style="word-wrap:break-word;">
}<br style="word-wrap:break-word;">
}<br style="word-wrap:break-word;">
// 实例化自定义的 BroadcastReceiver<br style="word-wrap:break-word;">
AlarmReceiver receiver = new AlarmReceiver();<br style="word-wrap:break-word;">
IntentFilter filter = new IntentFilter();<br style="word-wrap:break-word;">
filter.addAction("android.intent.action.BOOT_COMPLETED");&nbsp; &nbsp;&nbsp;<br style="word-wrap:break-word;">
// 以编程方式注册&nbsp;&nbsp;BroadcastReceiver 。xml配置方式见下<br style="word-wrap:break-word;">
// 一般在 OnStart 时注册,在 OnStop 时取消注册<br style="word-wrap:break-word;">
registerReceiver(receiver, filter);<br style="word-wrap:break-word;">
Intent intent = new Intent(this, AlarmReceiver.class);&nbsp;<br style="word-wrap:break-word;">
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0);&nbsp;<br style="word-wrap:break-word;">
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);&nbsp;<br style="word-wrap:break-word;">
//一次闹铃<br style="word-wrap:break-word;">
alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() +1000, pendingIntent);&nbsp;<br style="word-wrap:break-word;">
//周期闹铃<br style="word-wrap:break-word;">
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 1000, 10000, pendingIntent);&nbsp;<br style="word-wrap:break-word;">

Prev | Next
Pg.: 1 ... 4 5 6 7 8 9 10 11 12


Back to home | File page

Subscribe | Register | Login | N