package com.example.second;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class ThirdActivity extends Activity {
private Button relogin;
private Button callphone;//创建打电话b2对象
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_third);
relogin=(Button)findViewById(R.id.relogin);
callphone=(Button)findViewById(R.id.callphone);
//重新登录跳转到登录界面
relogin.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent in=new Intent(ThirdActivity.this,MainActivity.class);
startActivity(in);
}});//relogin
//调用系统电话服务
callphone.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent in2=new Intent();//创建in2意图对象
in2.setAction(Intent.ACTION_CALL);//指定意图动作,电话动作
in2.setData(Uri.parse("tel:100860000"));//指定电话号码,tel 为电话协议
startActivity(in2);//启动意图
}});//b2
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.third, menu);
return true;
}
}
ThirdActivity.java
最新推荐文章于 2020-05-08 11:37:14 发布