如下的代码即可以达到点击按钮实现home键的功能。
Intent intent = new Intent();
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
startActivity(intent);
android应用程序,由一到多个Activity组成.每个Activity没有很紧密的联系,
因为我们可以在自己的程序中调用其它Activity,
特别是调用自己的代码之外生成的Activity,
比如android提供的发短信或者打电话的Activity.
Intent call = new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+phonenumber);
startActivity(call);//打电话的Activity
Intent sms = new Intent(Intent.ACTION_SENDTO,Uri.parse("smsto:"+phonenumber);
startActivity(sms);//发短信的Activity