android3.1

### oefening 1 ###

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

    ...

	Intent browserIntent = new Intent("android.intent.action.VIEW",
	Uri.parse("https://developer.android.com/index.html"));
	startActivity(browserIntent);

	...

}

Download hier het bestand.
### oefening 2 ###

### activity_main.xml ###

<androidx.constraintlayout.widget...>
  
  ...

  <Button
      android:id="@+id/button1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Naar tweede scherm"
      android:onClick="startSecondActivity"/>
    
  ...

</androidx.constraintlayout.widget.ConstraintLayout>

### MainActivity.java ###

public class MainActivity extends AppCompatActivity {

  ...

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

}


Download hier het bestand.
### oefening 3 ###

### MainActivity.java ###

public class MainActivity extends AppCompatActivity {

  public static final String EXTRA_INFO = "default";

  ...

  public void startSecondActivity(View view) {
      ...
      intent.putExtra(EXTRA_INFO,"Dit bericht komt uit MainActivity");
      ...
  }
  
  ...

}

### activity_second.xml ###

<androidx.constraintlayout.widget...>
    
    ...

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    ...

</androidx.constraintlayout.widget.ConstraintLayout>

### SecondActivity.java ###

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

    ...

    Intent intent = getIntent();
    String mededeling = intent.getStringExtra(MainActivity.EXTRA_INFO);
    TextView textView = (TextView) findViewById(R.id.textView);
    textView.setText(mededeling);

    ...

}

Download hier het bestand.