Android跳转到系统联系人及拨号或短信界面

时间:2021-05-20

现在开发中的功能需要直接跳转到拨号、联系人、短信界面等等,查找了很多资料,自己整理了一下。

1、跳转到拨号界面,代码如下:

1)直接拨打

Intent intentPhone = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber)); startActivity(intentPhone);

2)跳转到拨号界面

Intent intent = newIntent(Intent.ACTION_DIAL,Uri.parse("tel:" + phoneNumber)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);

2、跳转到联系人页面,使用一下代码:

Intent intentPhone = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber)); startActivity(intentPhone);

以下内容为转载:

Android开发之Intent跳转到系统应用中的拨号界面、联系人界面、短信界面 现在开发中的功能需要直接跳转到拨号、联系人、短信界面等等,查找了很多资料,自己整理了一下。

//安装已经存在的apk String filePath="mnt/sdcard/abc.apk"; Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse("file://" + filePath), "application/vnd.Android.package-archive"); startActivity(intent);//直接跳到安装页面,但是还要点击按钮确定安装,还是取消安装 //卸载某应用 String packageName="org.adw.launcher2" Uri packageUri = Uri.parse("package:"+packageName);//包名,指定该应用 Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageUri); startActivity(uninstallIntent); //查看某一应用程序的信息 Uri uri=Uri.parse("package:"+packageName);//包名,指定该应用 Intent intent=new Intent("android.settings.APPLICATION_DETAILS_SETTINGS", uri); startActivity(intent); 2.浏览网页某一具体网址 Uri uri = Uri.parse("http://xxxxxxxxxxxxxxxxxxxxxxxx"); Intent intent = new Intent(Intent.ACTION_VIEW,uri); //加下面这句话就是启动系统自带的浏览器打开上面的网址, 不加下面一句话, 如果你有多个浏览器,就会弹出让你选择某一浏览器, 然后改浏览器就会打开该网址............... intent.setClassName("com.android.browser", "com.android.browser.BrowserActivity"); startActivity(intent); //系统 设置 界面 Intent intent=new Intent(); intent.setClassName("com.android.settings","com.android.settings.Settings"); startActivity(intent); //回到桌面吗 Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); startActivity(intent); //系统 拨号 界面 Intent intent= new Intent(Intent.ACTION_DIAL); intent.setClassName("com.android.contacts","com.android.contacts.DialtactsActivity"); startActivity(intent); //系统 通话记录 界面 Intent intent =new Intent(); intent.setAction("android.intent.action.CALL_BUTTON"); startActivity(intent); //拨号 Uri uri = Uri.parse("tel:xxxxxx"); Intent intent = new Intent(Intent.ACTION_DIAL, uri); startActivity(intent); //启动拨号界面,指定了类名 包名 是系统的拨号界面 DialtactsActivity Intent intent= new Intent("android.intent.action.DIAL"); intent.setClassName("com.android.contacts","com.android.contacts.DialtactsActivity"); startActivity(intent); //系统 联系人 界面 PeopleActivity Intent intent001 = new Intent(); intent001.setClassName("com.android.contacts","com.android.contacts.activities.PeopleActivity"); startActivity(intent001); //系统 搜索 界面 SearchActivity Intent intent002=new Intent(); intent002.setClassName("com.android.quicksearchbox", "com.android.quicksearchbox.SearchActivity"); startActivity(intent002); //启动短信收件箱的界面,指定了包名,类名 Intent intent4 = new Intent(); intent4.setClassName("com.android.mms","com.android.mms.ui.ConversationList"); startActivity(intent4); //启动联系人界面,不好 Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setData(Contacts.People.CONTENT_URI); startActivity(intent); 插入联系人 Intent intent=newIntent(Intent.ACTION_EDIT,Uri.parse("content://com.android.contacts/contacts/"+"1")); startActivity(intent); 到联系人列表界面 Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT); intent.setType("vnd.android.cursor.item/person"); intent.setType("vnd.android.cursor.item/contact"); intent.setType("vnd.android.cursor.item/raw_contact"); intent.putExtra(android.provider.ContactsContract.Intents.Insert.NAME, name); intent.putExtra(android.provider.ContactsContract.Intents.Insert.COMPANY,company); intent.putExtra(android.provider.ContactsContract.Intents.Insert.PHONE, tel); intent.putExtra(android.provider.ContactsContract.Intents.Insert.PHONE_TYPE, 3); //启动短信收件箱的界面,指定了包名,类名 Intent intent = new Intent(); intent.setClassName("com.android.mms","com.android.mms.ui.ConversationList"); startActivity(intent); //启动编辑短信的界面 Intent intent = new Intent(Intent.ACTION_VIEW); intent.setType("vnd.android-dir/mms-sms"); // intent.setData(Uri.parse("content://mms-sms/conversations/"));//此为号码 startActivity(intent); --------------------------------------------------------------- 2--------------------------------------------------------------- --------------------------------------------------------------- 现在开发中的功能需要直接跳转到拨号、联系人、短信界面等等,查找了很多资料,自己整理了一下。 首先,我们先看拨号界面,代码如下: Intent intent =new Intent(); intent.setAction("android.intent.action.CALL_BUTTON"); startActivity(intent); 和 Uri uri = Uri.parse("tel:xxxxxx"); Intent intent = new Intent(Intent.ACTION_DIAL, uri); startActivity(intent); 两者都行 但是如果是跳转到应用,使用一下代码: Intent intent= new Intent("android.intent.action.DIAL"); intent.setClassName("com.android.contacts","com.android.contacts.DialtactsActivity"); 到通话记录界面: Intent intent=new Intent(); intent.setAction(Intent.ACTION_CALL_BUTTON); startActivity(intent); 到联系人界面: Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Contacts.People.CONTENT_URI); startActivity(intent); 到应用: Intent intent= new Intent("com.android.contacts.action.LIST_STREQUENT"); intent.setClassName("com.android.contacts","com.android.contacts.DialtactsActivity"); 调用联系人界面: Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setData(Contacts.People.CONTENT_URI); startActivity(intent); 插入联系人 Intent intent=new Intent(Intent.ACTION_EDIT,Uri.parse("content://com.android.contacts/contacts/"+"1")); startActivity(intent); 到联系人列表界面 Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT); intent.setType("vnd.android.cursor.item/person"); intent.setType("vnd.android.cursor.item/contact"); intent.setType("vnd.android.cursor.item/raw_contact"); intent.putExtra(android.provider.ContactsContract.Intents.Insert.NAME, name); intent.putExtra(android.provider.ContactsContract.Intents.Insert.COMPANY,company); intent.putExtra(android.provider.ContactsContract.Intents.Insert.PHONE, tel); intent.putExtra(android.provider.ContactsContract.Intents.Insert.PHONE_TYPE, 3); 复制代码 到短信界面: Intent intent = new Intent(Intent.ACTION_VIEW); intent.setType("vnd.android-dir/mms-sms"); //intent.setData(Uri.parse("content://mms-sms/conversations/"));//此为号码 startActivity(intent); 到应用: Intent intent = new Intent("android.intent.action.CONVERSATION"); startActivity(intent); 以下是在网上找到的其他方法: 1.从google搜索内容 Intent intent = new Intent(); intent.setAction(Intent.ACTION_WEB_SEARCH); intent.putExtra(SearchManager.QUERY,"searchString") startActivity(intent); 2.浏览网页 Uri uri = Uri.parse("http://.android123.cwj"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); 26获取文件信息,并使用相对应软件打开 private void openFile(File f) { Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(android.content.Intent.ACTION_VIEW); String type = getMIMEType(f); intent.setDataAndType(Uri.fromFile(f), type); startActivity(intent); } private String getMIMEType(File f){ String end = f .getName() .substring(f.getName().lastIndexOf(".") + 1,f.getName().length()).toLowerCase(); String type = ""; if (end.equals("mp3") || end.equals("aac") || end.equals("aac")|| end.equals("amr") || end.equals("mpeg")|| end.equals("mp4")) { type = "audio"; } else if (end.equals("jpg") || end.equals("gif")|| end.equals("png") || end.equals("jpeg")) { type = "image"; } else { type = "*"; } type += "/*"; return type; } --------------------------------------------------------------- --------------------------------------------------------------- --------------------------------------------------------------- 现在开发中的功能需要直接跳转到拨号、联系人、短信界面等等,查找了很多资料,自己整理了一下。 1、跳转到拨号界面,代码如下: 1)直接拨打 Intent intentPhone = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber)); startActivity(intentPhone); 2)跳转到拨号界面 Intent intent = newIntent(Intent.ACTION_DIAL,Uri.parse("tel:" + phoneNumber)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); 2、跳转到联系人页面,使用一下代码: Intent intentPhone = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber)); startActivity(intentPhone); --------------------------------------------------------------- 3--------------------------------------------------------------- ---------------------------------------------------------------

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章