指定Action、Category调用系统Activity实例-点击按钮,返回Home桌面
来源:互联网 发布:手机淘宝不能图片搜索 编辑:程序博客网 时间:2024/06/09 20:16
该例子,点击返回Home桌面按钮,跳转到Home桌面
activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">
<Button android:id="@+id/backToHome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="返回Home桌面"
android:textSize="14dp"/>
</LinearLayout>
MainActivity.java
package com.example.backtohome;
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 MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button but=(Button) super.findViewById(R.id.backToHome);
but.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent();
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
startActivity(intent);
}
});
}
}
- 指定Action、Category调用系统Activity实例-点击按钮,返回Home桌面
- 指定Action、Category调用系统Activity
- 指定Action,Category调用系统Activity
- 使用指定的Action,Category调用系统Activity
- Android_指定Action和Category调用系统Activity
- 指定Action、Category调用系统Activty
- 返回系统HOME桌面
- 返回系统Home桌面
- Android中指定Action、Category调用系统Activity
- App Bar 点击返回按钮自动返回上一个指定的Activity
- 5 返回桌面 Intent的action 和 category 属性
- android-安装应用直接“打开”,home键返回桌面再次点击应用图标,重新启动MAIN_action的Activity
- 当跳转到一个activity后按home键返回桌面,再桌面点击app图标进入后app重启了
- android点击返回按钮时,两个activity的ondestory都被调用了
- Android返回Home桌面
- 如何实现在一个app里面点击按钮返回home
- 关于Android app首次安装完成后在安装界面打开应用再按home键返回桌面,重新进入app重复实例化launcher activity(转)
- Android 点击按钮调用系统照相机
- OJ_1036
- error LNK2005
- 如何避免僵尸进程
- Leetcode Maximum Depth of Binary Tree
- Spring MVC 与 itextpdf 集成实现PDF签名的maven包依赖冲突
- 指定Action、Category调用系统Activity实例-点击按钮,返回Home桌面
- OJ_1037 Powerful Calculator
- 云南老人毒死2个月大外孙 称为报复婴儿父母
- OJ_1038
- Remove Duplicates from Sorted Array II
- HDU 1403 Longest Common Substring
- title_test-1188220387
- title_test69996405
- title_test-1131689306