mainactivityandroid
package com.example.cie.zujiantongxin1; import android.content.Intent; import android.net.Uri; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity extends AppCompatActivity { Button mButtonExplicit, mButtonimplicit; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mButtonExplicit = (Button)findViewById(R.id.button); mButtonExplicit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(MainActivity.this, NewActivity.class); startActivity(intent); } }); mButtonimplicit = (Button)findViewById(R.id.button2); mButtonimplicit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.baidu.com")); startActivity(intent); } }); } }
newActivityapp
package com.example.cie.zujiantongxin1;import android.content.Intent;import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.view.View;import android.widget.Button;public class NewActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_new); }}