Android学习之Intent实现拨号、打开外部网页

拨号实现

  • app/src/main/java/包名/MainActivity.java
//拨号
Button button1 = findViewById(R.id.button22);
button1.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        Intent intent=new Intent(Intent.ACTION_DIAL);
        intent.setData(Uri.parse("tel:15690847920"));
        startActivity(intent);
    }
});

外部网页的实现

  • app/src/main/java/包名/MainActivity.java
//外部网页
Button button1 = (Button)findViewById(R.id.button32);
button1.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse("https://recclay.github.io/MyLove/"));
        startActivity(intent);
    }
});

猜你喜欢

转载自blog.csdn.net/ReCclay/article/details/81604961
今日推荐