zoukankan      html  css  js  c++  java
  • 常用Intent

    1.打开浏览器

    Uri uri = Uri.parse("http://www.baidu.com");
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    startActivity(intent); 

    2.外呼电话—拨号界面

    Uri uri = Uri.parse("tel:123456789");
    Intent intent = new Intent(Intent.ACTION_DIAL, uri);
    startActivity(intent);

    3.外呼电话—直接拨打

    Uri uri = Uri.parse("tel:123456789");
    Intent intent = new Intent(Intent.ACTION_CALL, uri);
    startActivity(intent);

    4.发送短信—调起短信页面

    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    intent.putExtra("sms_body", "SMS text"); 
    intent.setType("vnd.android-dir/mms-sms");
    startActivity(intent);

     5. 跳转到桌面,经常用于屏蔽后退键直接回到桌面

    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.addCategory(Intent.CATEGORY_MONKEY);
    startActivity(intent);

     屏蔽后退键,直接回到桌面

    @Override
    public void onBackPressed() {
        super.onBackPressed();
    
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.addCategory(Intent.CATEGORY_MONKEY);
        startActivity(intent);
    }
  • 相关阅读:
    MySQL主从数据库同步延迟问题解决(转)
    Python2.6升级Python2.7
    Socket网络编程
    Python 面向对象进阶
    Python类基础知识(面向对象基础)
    shell脚本中出现^M
    Centos6下Python3的编译安装
    Python成长之路(常用模块学习)
    SVN使用总结
    xshell锁屏
  • 原文地址:https://www.cnblogs.com/cbooy/p/4752973.html
Copyright © 2011-2022 走看看