android studio

[android] Intent ACTION_VIEW Uri.parse 외부 액티비티 띄우기

공부짱짱열심히하기 2023. 2. 7. 17:02
void selectContact(){
        Intent intent = new Intent(Intent.ACTION_PICK);
        intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
        startActivity(intent);
    }

    //웹브라우저 실행시키니는 인텐트
    void openWebPage(String url){
        Uri uri = Uri.parse(url);
        Intent intent = new Intent(Intent.ACTION_VIEW,uri);
        startActivity(intent);
    }

    // SMS 보내기위한 액티비티 띄우기
    void composeSMS(String phone){
        Uri uri = Uri.parse(phone);
        Intent intent = new Intent(Intent.ACTION_VIEW,uri);
        startActivity(intent);
    }


    // 이메일 작성하는 액티비티 띄윅
    void composeEmail(String[] adress, String subject){

        Uri uri = Uri.parse("mailto");
        Intent intent = new Intent(Intent.ACTION_SENDTO);
        intent.setData(uri);
        intent.putExtra(Intent.EXTRA_EMAIL,adress);
        intent.putExtra(Intent.EXTRA_SUBJECT,subject);
        startActivity(intent);
    }

 

void selectContact(){
        Intent intent = new Intent(Intent.ACTION_PICK);
        intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
        startActivity(intent);
    }

    //웹브라우저 실행시키니는 인텐트
    void openWebPage(String url){
        Uri uri = Uri.parse(url);
        Intent intent = new Intent(Intent.ACTION_VIEW,uri);
        startActivity(intent);
    }

    // SMS 보내기위한 액티비티 띄우기
    void composeSMS(String phone){
        Uri uri = Uri.parse(phone);
        Intent intent = new Intent(Intent.ACTION_VIEW,uri);
        startActivity(intent);
    }


    // 이메일 작성하는 액티비티 띄윅
    void composeEmail(String[] adress, String subject){

        Uri uri = Uri.parse("mailto");
        Intent intent = new Intent(Intent.ACTION_SENDTO);
        intent.setData(uri);
        intent.putExtra(Intent.EXTRA_EMAIL,adress);
        intent.putExtra(Intent.EXTRA_SUBJECT,subject);
        startActivity(intent);
    }