&nbsp; &nbsp; (SensorManager)getSystemService(Context.SENSOR_SERVICE);&nbsp;<br style="word-wrap:break-word;">
93 android 设置控件布局参数<br style="word-wrap:break-word;">
textView01.setLayoutParams<br style="word-wrap:break-word;">
(<br style="word-wrap:break-word;">
new AbsoluteLayout.LayoutParams(100,60,0,0);//高100,宽60,x=0,y=0;<br style="word-wrap:break-word;">
);<br style="word-wrap:break-word;">
94 android 创建Drawable对象<br style="word-wrap:break-word;">
Resources res = getResources();<br style="word-wrap:break-word;">
Drawable drawable = res.getDrawable(R.drawable.hh);<br style="word-wrap:break-word;">
95 android 访问网页<br style="word-wrap:break-word;">
Uri uri = Uri.parse("<a style="word-wrap:break-word;color:#336699;" href="http://www.google.com/" target="_blank">http://www.google.com</a>");<br style="word-wrap:break-word;">
Intent intent&nbsp;&nbsp;= new Intent(Intent.ACTION_VIEW,uri);<br style="word-wrap:break-word;">
startActivity(intent);<br style="word-wrap:break-word;">
96 android 打电话<br style="word-wrap:break-word;">
Uri uri = Uri.parse("tel:00000000");<br style="word-wrap:break-word;">
Intent intent = new Intent(Intent.ACTION_DIAL, uri);&nbsp;<br style="word-wrap:break-word;">
startActivity(intent);&nbsp;<br style="word-wrap:break-word;">
97 android 播放歌曲<br style="word-wrap:break-word;">
Intent intent = new Intent(Intent.ACTION_VIEW);<br style="word-wrap:break-word;">
Uri uri = Uri.parse("<a style="word-wrap:break-word;color:#336699;" href="http://www.apkbus.com/file:///sdcard/test.mp3" target="_blank">file:///sdcard/test.mp3</a>");<br style="word-wrap:break-word;">
intent.setDataAndType(uri, "audio/mp3");<br style="word-wrap:break-word;">
startActivity(intent);<br style="word-wrap:break-word;">
98 android 发送邮件<br style="word-wrap:break-word;">
Intent intent=new Intent(Intent.ACTION_SEND);&nbsp; &nbsp;&nbsp;&nbsp;<br style="word-wrap:break-word;">
intent.putExtra(Intent.EXTRA_TEXT, "The email text");&nbsp; &nbsp;&nbsp;&nbsp;<br style="word-wrap:break-word;">
intent.setType("text/plain");&nbsp; &nbsp;&nbsp;&nbsp;<br style="word-wrap:break-word;">
startActivity(Intent.createChooser(intent, "Choose Email Client"));<br style="word-wrap:break-word;">
99 android 发短信<br style="word-wrap:break-word;">
Uri uri = Uri.parse("smsto:123456789");&nbsp;<br style="word-wrap:break-word;">
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);&nbsp; &nbsp;<br style="word-wrap:break-word;">
intent.putExtra("sms_body", "The SMS text");&nbsp; &nbsp;<br style="word-wrap:break-word;">
startActivity(intent);<br style="word-wrap:break-word;">
100 android 安装程序<br style="word-wrap:break-word;">
Uri installUri = Uri.fromParts("package", "xxx", null);<br style="word-wrap:break-word;">
Intent intent = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);&nbsp;<br style="word-wrap:break-word;">
startActivity(intent);<br style="word-wrap:break-word;">
101 android 卸载程序<br style="word-wrap:break-word;">
Uri uninstallUri = Uri.fromParts("package", "xxx", null);<br style="word-wrap:break-word;">
Intent intent = new Intent(Intent.ACTION_DELETE, uninstallUri);&nbsp;<br style="word-wrap:break-word;">
startActivity(intent);<br style="word-wrap:break-word;">
102 android 从xml配置获得控件对象<br style="word-wrap:break-word;">
//TestActivity.java<br style="word-wrap:break-word;">
textView = (TextView) findViewById(R.id.TextView01);<br style="word-wrap:break-word;">
//main.xml<br style="word-wrap:break-word;">
&lt; TextView android:text = "TextView01"<br style="word-wrap:break-word;">
android:id = "@+id/TextView01"<br style="word-wrap:break-word;">
android:layout_width = "wrap_content"<br style="word-wrap:break-word;">
android:layout_height = "wrap_content"<br style="word-wrap:break-word;">
android:layout_x = "60px"<br style="word-wrap:break-word;">
android:layout_y = "60px"/&gt;<br style="word-wrap:break-word;">
103 android 获得触摸屏压力<br style="word-wrap:break-word;">
public boolean onTouch(View v, MotionEvent event) {<br style="word-wrap:break-word;">
float pressure = event.getPressure();<br style="word-wrap:break-word;">
return false;<br style="word-wrap:break-word;">
}<br style="word-wrap:break-word;">
104 android 给文本加上滚动条<br style="word-wrap:break-word;">
TextView textView = new TextView(this);<br style="word-wrap:break-word;">
textView.setText(string);<br style="word-wrap:break-word;">
ScrollView scrollView = new ScrollView(this);<br style="word-wrap:break-word;">
scrollView.addView(textView);<br style="word-wrap:break-word;">
setContentView(scrollView);<br style="word-wrap:break-word;">
105 android 获得正在运行的所有服务<br style="word-wrap:break-word;">
public void onCreate(Bundle savedInstanceState) {<br style="word-wrap:break-word;">
super.onCreate(savedInstanceState);<br style="word-wrap:break-word;">
StringBuffer serviceInfo = new StringBuffer();<br style="word-wrap:break-word;">
ActivityManager activityManager = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);<br style="word-wrap:break-word;">
List&lt;RunningServiceInfo&gt; services = activityManager.getRunningServices(256);<br style="word-wrap:break-word;">
Iterator&lt;RunningServiceInfo&gt; iterator = services.iterator();<br style="word-wrap:break-word;">
while (iterator.hasNext()) {<br style="word-wrap:break-word;">
RunningServiceInfo si = (RunningServiceInfo)iterator.next();<br style="word-wrap:break-word;">
serviceInfo.append("pid: ").append(si.pid);<br style="word-wrap:break-word;">
serviceInfo.append("process: ").append(si.process);<br style="word-wrap:break-word;">
}<br style="word-wrap:break-word;">
TextView textView = new TextView(this);<br style="word-wrap:break-word;">
textView.setText(serviceInfo.toString());<br style="word-wrap:break-word;">
ScrollView scrollView = new ScrollView(this);<br style="word-wrap:break-word;">
scrollView.addView(textView);<br style="word-wrap:break-word;">
setContentView(scrollView);<br style="word-wrap:break-word;">
}<br style="word-wrap:break-word;">
106 android 使用ContentResolver获得联系人姓名和号码<br style="word-wrap:break-word;">
ContentResolver cr = getContentResolver();<br style="word-wrap:break-word;">
Cursor cur = cr.query(People.CONTENT_URI, null, null, null, null);<br style="word-wrap:break-word;">

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


Back to home | File page

Subscribe | Register | Login | N