> For the complete documentation index, see [llms.txt](https://johch3n611u.gitbook.io/c50108/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://johch3n611u.gitbook.io/c50108/ju-li-cheng-bei/201906/20190605java-jie-mian-zuo-shu-+-an-zhuo-gong-zuo-shi-zheng-he-layoutjavaintent-yi-bundle-bao-guo.md).

# 2019/0605/Java介面實作&結束+安卓工作室(整合Layout與Java)Intent意圖\&Bundle包裹

\#Java

前情提要 類別&#x20;

### ##繼承 介面 實作 / 抽象類別 override&#xD;

多型呼叫處理

![](/files/-LgudqUvI-s9nV_VqAfO)

![](/files/-LgudvMEtrpktQaIY9kH)

作業五 講解&#x20;

下午 Inttent 資料傳遞 畫面整合

![](/files/-Lgue-slQPITx1nObsgE)

![](/files/-Lgue3IuQFoigpPkHqP4)

![](/files/-Lgue7yHcX45K2xHCYKC)

![](/files/-Lgue9midUD_LELrLdns)

### 意圖與程式生命週期

![](/files/-LgueE-OhzBERZtAIDcv)

獨立活動 沒有資料交換 前景轉背景轉B畫面

相依活動 傳遞資料至下一個活動

![](/files/-LgueJKeAVPYmq7lk8qx)

![](/files/-LgueMN2DRn7nnBnaJWk)

![](/files/-LgueYjksdCCLYLUW8Kp)

![](/files/-LguebY2B4NmrkzwOTmm)

![](/files/-LguefI1AHPURoryAcsO)

![](/files/-Lguenm-sHdrqY_wVqSE)

![](/files/-Lguer-Qb8m6RAGbohxo)

![](/files/-LgueuPBdqqSA3cABAQK)

![](/files/-LguexnEybmCj2UxuAIj)

![](/files/-Lguf-hg_oRuDRpm62Yp)

![](/files/-Lguf2nrtBw5LzMMp6q-)

![](/files/-Lguf8PTiEB2i7Z4upIS)

![](/files/-LgufCK4jjzCqhHAI8SA)

![](/files/-LgufFrlQyNvXlf7uzhP)

修改前最好做備份

![](/files/-LgufLbJjAm2goNhz9Nh)

![](/files/-LgufP60KJKEqt6Nvrn-)

APP 很多 Activity 切換 利用 Intent

![](/files/-LgufSw5ZRjvzne_DcqQ)

![](/files/-LgufWJwaPmCWXdJi3MX)

![](/files/-LgufZ5yG8p8KC8gtmTA)

![](/files/-Lgufb7m8xzvX9TH6j5_)

![](/files/-LgufkbRSzkeN4Vrq3-2)

Values dimens.xml

![](/files/-Lgufu8FqEIXddr8LMmd)

![](/files/-LgufxO5s2Z2scxbsu8H)

![](/files/-Lgug-mUV288KS_jjqhO)

### ## alt + enter 快速引入package&#xD;

這個就沒有傳遞參數

### Intent 意圖使用方式

#### ###E:\android\Intent01\app\src\main\java\com\example\intent01\MainActivity.java&#xD;

```

package com.example.intent01;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.content.Intent;
import android.view.View;


public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void button_Click(View v){
        Intent intent = new Intent(this,SecondActivity.class);
        startActivity(intent);
    }

    public void button01_Click(View v){
        Intent intent = new Intent(this,ThreeActivity.class);
        startActivity(intent);
    }


}

```

#### ###E:\android\Intent01\app\src\main\java\com\example\intent01\SecondActivity.java

```
package com.example.intent01;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class SecondActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
    }

    public void button2_Click(View v){
        finish();
    }
}

```

#### ###E:\android\Intent01\app\src\main\java\com\example\intent01\ThreeActivity.java

```
package com.example.intent01;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class ThreeActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_three);
    }

    public void button2_Click(View v){
        finish();
    }
}

```

![](/files/-LgugJTEBaN0CPX3gNHb)

![](/files/-LgugNVeyY9ZxvQAnzXr)

![](/files/-LgugQt2R7mTDpCycC6m)

![](/files/-LgugTjJoeJbpRDir888)

![](/files/-LgugWmaSZqSfSa6I0Oc)

![](/files/-LgugZdHdnA6en64Ojom)

![](/files/-LgugbVFe6qJstCst3kx)

![](/files/-LgugeBQdsEt3cPad7YO)

自動在讀取完後顯示 要寫在 onCreate

![](/files/-LgugiGhigvxdsOn1oYo)

### bundle 包裹使用方式

#### ###FActivity

```
package com.example.intent02;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class FActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_f);
        convertTempture();
    }

    public void convertTempture(){
        int c;
        double f = 0.0;
        Bundle bundle = this.getIntent().getExtras();

        if(bundle != null){
            c = Integer.parseInt(bundle.getString("TEMPC"));
            f = (9.0 * c) / 5 + 32;
            TextView o = findViewById(R.id.lblOutput);
            o.setText("華氏溫度:"+Double.toString(f));
        }
    }




    public  void button2_Click(View V){
        finish();
    }
}

```

#### ### MainActivity

```
package com.example.intent02;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void button_Click(View V){
        EditText txtC = findViewById(R.id.txtC);
        Intent intent = new Intent(this,FActivity.class);
        Bundle bundle = new Bundle();
        bundle.putString("TEMPC",txtC.getText().toString());
        intent.putExtras(bundle);
        startActivity(intent);
    }
}

```

### 下次預告

![](/files/-LgugyOFSKrdVl8ChK3o)
