Intent一般可被用于启动活动,启动服务,以及发送广播等场景,由于服务,广播。intent的用法分为两种,隐式启动和显示启动。
1.启动一个界面语法:
Intent intent=new Intent(this,next.class)。this代表的是我们一个当前的Activity,next.class表示的是即将跳转的activity。
2.显示启动界面,发短信,打电话。
public class activity_phone extends Activity {
private Button mBtnPhone;
private TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_phone);
textView = (TextView) findViewById(R.id.textView);
mBtnPhone = (Button) findViewById(R.id.button_phone);
mBtnPhone.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(intent.ACTION_CALL);
intent.setData(Uri.parse("tel:13893146092"));
startActivity(intent);
}
});
Button button = (Button) fin