add to dictionary 메뉴를 통해 Userdictionary로 startActivity를 할 때,
GB와 달리 ICS에선 이 Activity도 Recent App으로 나타난다는 점이 문제가 된다.
이를 막기 위해 다음 시도를 하는데...
if (suggestionInfo.suggestionIndex == ADD_TO_DICTIONARY) {
Intent intent = new Intent(Settings.ACTION_USER_DICTIONARY_INSERT);
intent.putExtra("word", originalText);
intent.putExtra("locale", getTextServicesLocale().toString());
intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);
getContext().startActivity(intent);
// There is no way to know if the word was indeed added. Re-check.
// TODO The ExtractEditText should remove the span in the original text instead
editable.removeSpan(suggestionInfo.suggestionSpan);
updateSpellCheckSpans(spanStart, spanEnd, false);
} else {
위 빨간 글씨 부분을 FLAG_ACTIVITY_CLEAR_TOP로 변경하는 것이다.
/**
* If set, and the activity being launched is already running in the
* current task, then instead of launching a new instance of that activity,
* all of the other activities on top of it will be closed and this Intent
* will be delivered to the (now on top) old activity as a new Intent.
*
* <p>For example, consider a task consisting of the activities: A, B, C, D.
* If D calls startActivity() with an Intent that resolves to the component
* of activity B, then C and D will be finished and B receive the given
* Intent, resulting in the stack now being: A, B.
*
* <p>The currently running instance of activity B in the above example will
* either receive the new intent you are starting here in its
* onNewIntent() method, or be itself finished and restarted with the
* new intent. If it has declared its launch mode to be "multiple" (the
* default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
* the same intent, then it will be finished and re-created; for all other
* launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
* Intent will be delivered to the current instance's onNewIntent().
*
* <p>This launch mode can also be used to good effect in conjunction with
* {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
* of a task, it will bring any currently running instance of that task
* to the foreground, and then clear it to its root state. This is
* especially useful, for example, when launching an activity from the
* notification manager.
*
* <p>See
* <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
* Stack</a> for more information about tasks.
*/
public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
근데 내 생각엔 다음 flag가 더 적절하지 않나 싶다.
/**
* If set, the new activity is not kept in the history stack. As soon as
* the user navigates away from it, the activity is finished. This may also
* be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
* noHistory} attribute.
*/
public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
한번 검토해 보길.
'Work' 카테고리의 다른 글
Summary of my work experience (0) | 2012.04.06 |
---|---|
FULL_SCREEN 화면에서 StatusBar 나타나는 현상 (0) | 2012.04.03 |
SGP IT corps (0) | 2012.01.02 |
How about some Android graphics true facts? (0) | 2011.12.05 |
Android TextureView에 관한 Google commit logs (0) | 2011.11.18 |