Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.setPackage("com.kakao.talk");
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, contents);
startActivity(intent);
위와 같이 카카오톡을 실행하면
마시멜로버전에서
1.친구에게공유, 2.나에게 를 선택하는 CHOOSER가 뜹니다.
문제는 둘 중에 하나를 선택하면 이 후에는 CHOOSER없이 이 전에 선택한 값으로 고정이 되어 실행됩니다.
고정없이 실행되었으면 하는데 해결 방안이 있을까요?
저도 궁금하네요. 요건 안드 일반 지식 또는 카톡 지식이 필요할것 같은디…
저도 이 부분이 궁금합니다.
한번 선택하면 수정이 불가능한데 제어 불가능한가요 ???
안녕하세요! 위 코드 방식으로 공유를 하게 되면 선택했던 값을 기억하게 됩니다. 항상 chooser를 띄우기 위해서는
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));
위처럼 Intent.createChooser 메소드를 사용하셔야 해요~ 안드로이드 개발자 사이트에 보시면 해당 관련 부분이 나와있어요
If there’s an installed application with a filter that matches ACTION_SEND and MIME type text/plain, the Android system will run it; if more than one application matches, the system displays a disambiguation dialog (a “chooser”) that allows the user to choose an app.
However, if you call Intent.createChooser(), passing it your Intent object, it returns a version of your intent that will always display the chooser. This has some advantages:
Even if the user has previously selected a default action for this intent, the chooser will still be displayed.
If no applications match, Android displays a system message.
You can specify a title for the chooser dialog.
https://developer.android.com/training/sharing/send.html
1개의 좋아요