Page 287 - MDP2022-3
P. 287
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, 101);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { // 갤러리
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 101) {
if (resultCode == RESULT_OK) {
MediaController mc = new MediaController(this); // 비디오 컨트롤 가능하게(일시정지, 재시작 등)
videoView.setMediaController(mc);
Uri fileUri = data.getData();
videoView.setVideoPath(String.valueOf(fileUri)); // 선택한 비디오 경로 비디오뷰에 셋
videoView.start(); // 비디오뷰 시작
}
}
}
public void onButtonClicked3(View v) {
Toast.makeText(this, "전화창으로 이동", Toast.LENGTH_LONG).show();
Intent intent = new Intent(this ,SubActivity.class);
startActivity(intent);
}
}
SubActivity.java
package com.example.a777;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class SubActivity extends AppCompatActivity implements View.OnClickListener {
private Button mCall;
private Button mDialogCall;
private EditText mEditNumber;
private String mNum;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.call);
mCall = (Button) findViewById(R.id.btnCall);
mDialogCall = (Button) findViewById(R.id.btnDialog);
mEditNumber = (EditText) findViewById(R.id.edtNumber);
mCall.setOnClickListener(this);
mDialogCall.setOnClickListener(this);
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull
int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if(requestCode == 3924) {
if(grantResults.length >= 1) {