0% menganggap dokumen ini bermanfaat (0 suara)
6 tayangan7 halaman

Tugas 6 Intent

Pemrograman mobile

Diunggah oleh

renaldipp
Hak Cipta
© © All Rights Reserved
Kami menangani hak cipta konten dengan serius. Jika Anda merasa konten ini milik Anda, ajukan klaim di sini.
Format Tersedia
Unduh sebagai DOCX, PDF, TXT atau baca online di Scribd
0% menganggap dokumen ini bermanfaat (0 suara)
6 tayangan7 halaman

Tugas 6 Intent

Pemrograman mobile

Diunggah oleh

renaldipp
Hak Cipta
© © All Rights Reserved
Kami menangani hak cipta konten dengan serius. Jika Anda merasa konten ini milik Anda, ajukan klaim di sini.
Format Tersedia
Unduh sebagai DOCX, PDF, TXT atau baca online di Scribd
Anda di halaman 1/ 7

Nama kelompok :

1. Ahmad Zaid Vagas (1913012)


2. Afif Firdaus (1913033)
3. Anisa Diah P (1913035)
4. Sisca Aldevia Azizah (1913039)
5. Khusnatul Asma (1913050)
TUGAS INTENT 1

Activity xml 1
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="KLIK EXPLICIT INTENT"
android:layout_marginTop="100dp"
android:layout_marginLeft="100dp"/>

<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="KLIK IMPLICIT INTENT"
android:layout_marginTop="150dp"
android:layout_marginLeft="100dp"/>
</RelativeLayout>

Activity xml 2
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Intent1">

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="KEEP HEALTHY GUYS"
android:layout_marginTop="50dp"
android:layout_marginLeft="98dp"
android:textSize="20dp"/>

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="110dp"
android:text="Olahraga WorkOut :
Tim peneliti dari The Human Performance Institute di Orlando, Fla., menjabarkan 7
Minute Workout sebagai kombinasi dari 12 macam latihan yang dilakukan selama 30 detik,
dengan diselingi istirahat 10 detik di antara latihan satu dan latihan
lainnya.Meskipun olahraga ini dilakukan hanya dalam tujuh menit, metode yang digunakan
sebenarnya membawa Anda keluar dari zona nyaman Anda. Semakin Anda terbiasa
melakukannya, Anda harus meningkatkan tingkat kesulitan sedikit demi sedikit." />

<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="KEMBALI KE AWAL"
android:layout_marginTop="290dp"
android:layout_marginLeft="110dp"/>
</RelativeLayout>

MainACtivity Java 1
package com.example.intent1;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.Button;
import android.content.Intent;
import android.view.View;
import android.net.Uri;

public class MainActivity extends AppCompatActivity {

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

Button awal1 = findViewById(R.id.button);


Button awal2 = findViewById(R.id.button2);

awal1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent eksplisit = new Intent(MainActivity.this,Intent1.class);
startActivity(eksplisit);
}
});

awal2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent inplisit = new Intent (Intent.ACTION_VIEW,
Uri.parse("https://hellosehat.com/"));
startActivity(inplisit);
}
});
}
}

MainActivity Java 2
package com.example.intent1;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.content.Intent;

public class Intent1 extends AppCompatActivity {

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

Button awal12 = findViewById(R.id.button3);

awal12.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent eksplisit = new Intent(Intent1.this,MainActivity.class);
startActivity(eksplisit);
}
});
}
}

TUGAS INTENT EKSTRA


Activity xml 1
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Halaman Utama"
android:layout_centerHorizontal="true"
android:layout_marginTop="80dp" />

<EditText
android:id="@+id/editText"
android:layout_width="301dp"
android:layout_height="wrap_content"
android:layout_marginLeft="58dp"
android:layout_marginTop="100dp"
android:layout_below="@+id/textView"
android:ems="10"
android:inputType="textPersonName"
android:text="SELAMAT DATANG DI ITN MALANG" />

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="INTENT WITH EXTRA"
android:layout_marginTop="100dp"
android:layout_below="@+id/editText"
android:layout_centerHorizontal="true"/>
</RelativeLayout>

Activity xml 2
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Inten2">

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Halaman Berikutnya"
android:layout_centerHorizontal="true"
android:layout_marginTop="80dp"
android:textSize="15sp"/>

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SELAMAT DATANG DI ITN MALANG"
android:layout_centerHorizontal="true"
android:layout_below="@+id/textView2"
android:layout_marginTop="150dp"
android:textSize="20sp" />
</RelativeLayout>

MainActivity Java 1
package com.example.intentextra;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

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

Button klik = (Button) findViewById(R.id.button);


final EditText isidata = (EditText) findViewById(R.id.editText);

klik.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent ekstra = new Intent(MainActivity.this, Inten2.class);

ekstra.putExtra("isidata", isidata.getText().toString());

startActivity(ekstra);
}
});

}
}
MainActivity Java 2
package com.example.intentextra;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.TextView;

public class Inten2 extends AppCompatActivity {

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

TextView data = (TextView) findViewById(R.id.textView3);


Bundle bundle = getIntent().getExtras();
String s = bundle.getString("isidata");
data.setText(s);

}
}

Anda mungkin juga menyukai