企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
几个Action属性和Data属性的特殊组合: ACTION_VIEW content://com.android.contacts/contacts/1:显示标识为1的联系人的信息 ACTION_EDIT content://com.android.contacts/contacts/1:编辑标识为1的联系人的信息 ACTION_DIAL content://com.android.contacts/contacts/1:显示向标识为1的联系人拨号的界面 ACTION_VIEW tel:123:显示向指定号码123拨号的界面 ACTION_DIAL tel:123:显示向指定号码123拨号的界面 ACTION_VIEW content://contacts/people/:显示所有联系人列表的信息,通过这种组合可以方便地查看系统联系人 MainActivity.java ~~~ package com.hust.actiondataonsystemactivity; import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button brower=(Button) findViewById(R.id.button1); Button edit=(Button) findViewById(R.id.button2); Button call=(Button) findViewById(R.id.button3); //浏览网页 brower.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent =new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse("http://www.baidu.com")); startActivity(intent); } }); //编辑联系人页面 edit.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent =new Intent(); intent.setAction(Intent.ACTION_EDIT); intent.setData(Uri.parse("content://com.android.contacts/contacts/2")); startActivity(intent); } }); //拨号页面 call.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { // TODO Auto-generated method stub Intent intent =new Intent(); intent.setAction(Intent.ACTION_DIAL); intent.setData(Uri.parse("tel:02780108225")); startActivity(intent); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } ~~~ ![](https://box.kancloud.cn/2016-03-10_56e0d9b1a6d1b.jpg) ![](https://box.kancloud.cn/2016-03-10_56e0d9b1bd60c.jpg) ![](https://box.kancloud.cn/2016-03-10_56e0d9b1ddc78.jpg) ![](https://box.kancloud.cn/2016-03-10_56e0d9b1f4086.jpg)