美文网首页
Android Intent 跳转

Android Intent 跳转

作者: 周晓风 | 来源:发表于2017-07-07 16:47 被阅读70次

    1.跳转拨号页面

    Intent intent=new Intent();

    intent.setAction(Intent.ACTION_CALL_BUTTON);

    startActivity(intent);

    2.跳转拨号页面(带号码)

    Uri uri = Uri.parse("tel:18510515551");

    Intent intent = new Intent(Intent.ACTION_DIAL, uri);

    startActivity(intent);

    3.跳转联系人页面

    Intent intent = new Intent();

    intent.setAction(Intent.ACTION_VIEW);

    intent.setData(Contacts.People.CONTENT_URI);

    startActivity(intent);

    4.跳转联系人页面(选择联系人)

    Intent intent = new Intent();

    intent.setAction(Intent.ACTION_PICK);

    intent.setData(Contacts.People.CONTENT_URI);

    startActivity(intent);

    5.插入联系人

    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);

    startActivity(intent);

    6.跳转短信页面

    Intent intent = new Intent(Intent.ACTION_VIEW);

    intent.setType("vnd.android-dir/mms-sms");

    intent.setData(Uri.parse("content://mms-sms/conversations/"));//此为号码

    startActivity(intent);

    7.发送短信页面

    Uri uri = Uri.parse("smsto:"+number);

    Intent intent = new Intent(Intent.ACTION_SENDTO,uri);

    intent.putExtra("sms_body", "text");

    intent.setType("vnd.android-dir/mms-sms");

    startActivity(intent);

    8.插入一条短信

    ContentValues content = new ContentValues();

    content.put("type", "1");

    content.put("address","短信地址");

    content.put("body", "短信内容");

    getContentResolver().insert(Uri.parse("content://sms/inbox"), content);

    9.跳转系统搜索(Google框架)

    Intent intent = new Intent();

    intent.setAction(Intent.ACTION_WEB_SEARCH);

    intent.putExtra(SearchManager.QUERY,"searchString")

    startActivity(intent);

    10.跳转浏览器

    Uri uri = Uri.parse("http://www.google.com");

    Intent intent = new Intent(Intent.ACTION_VIEW,uri);

    startActivity(intent);

    11.跳转地图(Google框架)

    Uri uri = Uri.parse("geo:32.125721,-56.523467");

    Intent intent = new Intent(Intent.Action_VIEW,uri);

    startActivity(intent);

    12.跳转音视频播放

    Intent intent = new Intent(Intent.ACTION_VIEW);

    Uri uri = Uri.parse("file:///sdcard/test.mp3");

    intent.setDataAndType(uri, "audio/mp3");

    startActivity(intent);

    13.跳转相机拍照(返回图片地址)

    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);

    startActivityForResult(intent,code);

    14.跳转系统相册(返回图片地址)

    Intent intent = new Intent();

    intent.setType("image/*");

    intent.setAction(Intent.ACTION_GET_CONTENT);

    startActivityForResult(intent, code);

    15.跳转录音机

    Intent intent = new Intent(Media.RECORD_SOUND_ACTION);

    startActivity(intent);

    16.跳转应用市场(Google框架)

    Uri uri = Uri.parse("market://search?q=pname:pkg_name");

    Intent intent = new Intent(Intent.ACTION_VIEW, uri);

    startActivity(intent);

    17.跳转其他应用(包名,Activity路径)

    Intent intent= new Intent();

    ComponentName cn = new ComponentName("com.android","com.android.MainActivity");

    intent.setComponent(cn);

    intent.setAction("android.intent.action.MAIN");

    startActivityForResult(intent, RESULT_OK);

    18.安装 apk

    Uri uri = Uri.fromParts("package", "xxx", null);

    Intent intent = new Intent(Intent.ACTION_PACKAGE_ADDED, uri);

    startActivity(intent);

    19.卸载 apk

    Uri uri = Uri.fromParts("package", strPackageName, null);

    Intent intent = new Intent(Intent.ACTION_DELETE, uri);

    startActivity(intent);

    相关文章

      网友评论

        本文标题:Android Intent 跳转

        本文链接:https://www.haomeiwen.com/subject/aicrhxtx.html