注意
示例代码
package com.example.www.activitydemo;
import android.Manifest;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
requestPermissions(new String[]{Manifest.permission.CALL_PHONE}, 200);
}
/*
*
* 调用打电话的 activity
* */
public void click(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + 183012));
startActivity(intent);
}
/*
* 隐式跳转
* */
public void click2(View v) {
Intent intent = new Intent();
intent.setAction("testActivity");
startActivity(intent);
}
/*
*
* 显式跳转到 某个应用 的某个 activity下面
* */
public void click3(View v) {
Intent intent = new Intent();
intent.setClassName("com.example.www.activitydemo", "com.example.www.activitydemo.Test2Activity");
startActivity(intent);
}
/*
* 显式跳转到本应用下面的 某个 activity
* */
public void click4(View view) {
Intent intent = new Intent();
intent.setClass(getApplicationContext(), TestActivity.class);
startActivity(intent);
}
/*
* 显式跳转到本应用下面的 某个 activity
* */
public void click5(View view) {
Intent intent = new Intent(getApplicationContext(), TestActivity.class);
startActivity(intent);
}
}