다음 코드를 사용하여 Share 메뉴를 통해 다른 응용 프로그램에서 내 응용 프로그램으로 TEXT를 보내고 EditText에 TEXT를 표시합니다.공유 메뉴를 통해 전송 된 텍스트 문자열 서식 지정 방법
Intent receivedIntent = getIntent();
String receivedAction = receivedIntent.getAction();
String receivedType = receivedIntent.getType();
TextView txtView = (EditText) findViewById(R.id.edWord);
//if(receivedAction.equals(Intent.ACTION_SEND)){
if (Intent.ACTION_SEND.equals(receivedAction) && receivedType != null) {
if(receivedType.startsWith("text/")) {
String receivedText = receivedIntent.getStringExtra(Intent.EXTRA_TEXT).toLowerCase();
if (receivedText != null)
{
txtView.setText(receivedText);
txtView.requestFocus();
ListView myList=(ListView) findViewById(R.id.lstWord);
myList.setFocusableInTouchMode(true);
myList.setSelection(0);
}
else
txtView.setText("");
}
}
모든 즉, 잘 작동, 전송 된 텍스트는 내 글고 치기 (위의 코드에서, 즉 edWord
)에 표시됩니다. 그러나 Share를 통해 전송 된 텍스트는 때때로 의미가없는 요소 또는 파생물로 구성됩니다 (예 : "word
, word'
, word,
또는 looked
, books
, tomatoes
).
내가 원하는 것은 EditText에 추가되기 전에 실제 단어 또는 기본 단어 형식 만 포함하도록 텍스트 서식을 지정하는 것입니다.
나는 approximate string matching
또는 fuzzy searching
에 대해 들었지만 내 코드에 어떻게 적용 할 것인지 잘 모릅니다. 나는 적어도 위의 문제를 해결하기 위해 당신이 나에게 약간의 도움을 줄 수 있을지 궁금해한다.
미리 감사드립니다.