码迷,mamicode.com
首页 > 其他好文 > 详细

Activity 的任务栈

时间:2016-06-08 20:29:56      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:

技术分享技术分享技术分享

 1 package com.example.metrox.l7;
 2 
 3 import android.content.Intent;
 4 import android.support.v7.app.AppCompatActivity;
 5 import android.os.Bundle;
 6 import android.view.View;
 7 import android.widget.Button;
 8 import android.widget.TextView;
 9 
10 public class MainActivity extends AppCompatActivity {
11 
12     @Override
13     protected void onCreate(Bundle savedInstanceState) {
14         super.onCreate(savedInstanceState);
15         setContentView(R.layout.activity_main);
16         ((TextView) findViewById(R.id.taskView)).setText(String.format("任务ID:%d\n,当前实例ID:%s",getTaskId(),toString()));
17         findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
18             @Override
19             public void onClick(View view) {
20                 startActivity(new Intent(MainActivity.this,MainActivity.class));
21             }
22         });
23 
24         findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
25             @Override
26             public void onClick(View view) {
27                 startActivity(new Intent( MainActivity.this,Baty.class));
28             }
29         });
30     }
31 }
 1 package com.example.metrox.l7;
 2 
 3 import android.content.Intent;
 4 import android.support.v7.app.AppCompatActivity;
 5 import android.os.Bundle;
 6 import android.view.View;
 7 import android.widget.TextView;
 8 
 9 public class Baty extends AppCompatActivity {
10 
11     @Override
12     protected void onCreate(Bundle savedInstanceState) {
13         super.onCreate(savedInstanceState);
14         setContentView(R.layout.activity_baty);
15         ((TextView) findViewById(R.id.textView)).setText(String.format("任务ID:%d\n,当前实例ID:%s",getTaskId(),toString()));
16 
17         findViewById(R.id.startm).setOnClickListener(new View.OnClickListener() {
18             @Override
19             public void onClick(View view) {
20                 startActivity(new Intent(Baty.this,MainActivity.class));
21             }
22         });
23     }
24 }
 1 <?xml version="1.0" encoding="utf-8"?>
 2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
 3     package="com.example.metrox.l7">
 4 
 5     <application
 6         android:allowBackup="true"
 7         android:icon="@mipmap/ic_launcher"
 8         android:label="@string/app_name"
 9         android:supportsRtl="true"
10         android:theme="@style/AppTheme">
11         <activity
12             android:name=".MainActivity"
13             android:label="Mian"
14             android:launchMode="sin">
15             <intent-filter>
16                 <action android:name="android.intent.action.MAIN" />
17 
18                 <category android:name="android.intent.category.LAUNCHER" />
19             </intent-filter>
20         </activity>
21         <activity android:name=".Baty" android:label="Baty"></activity>
22     </application>
23 
24 </manifest>

 

Activity 的任务栈

标签:

原文地址:http://www.cnblogs.com/linhongquan/p/5571209.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!