Android 首次建立聯絡人不顯示輸入法鍵盤
阿新 • • 發佈:2019-01-08
- alps/packages/apps/Contacts/src/com/android/contacts/editor/CompactContactEditorFragment.java
--- a/alps/packages/apps/Contacts/src/com/android/contacts/editor/CompactContactEditorFragment.java +++ b/alps/packages/apps/Contacts/src/com/android/contacts/editor/CompactContactEditorFragment.java @@ -50,7 +50,10 @@ import android.widget.Toast; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.List; +import android.os.Handler; +import android.view.inputmethod.InputMethodManager; /** * Contact editor with only the most important fields displayed initially. */ @@ -59,6 +62,10 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl public static final String TAG = "CompactContactEditorFragment"; private static final String KEY_PHOTO_RAW_CONTACT_ID = "photo_raw_contact_id"; private static final String KEY_UPDATED_PHOTOS = "updated_photos"; + private View mMainView; + private Handler mHandler ; private long mPhotoRawContactId; private Bundle mUpdatedPhotos = new Bundle(); @@ -81,9 +88,36 @@ public class CompactContactEditorFragment extends ContactEditorBaseFragment impl final View view = inflater.inflate( R.layout.compact_contact_editor_fragment, container, false); mContent = (LinearLayout) view.findViewById(R.id.raw_contacts_editor_view); + mMainView = view; + mHandler = new Handler(); return view; } + @Override + public void onResume() { + super.onResume(); + Log.i(TAG, "[onResume]."); + mHandler.post(new Runnable() { + + @Override + public void run() { + //M: getActivity return may NULL,judge before using + Activity activity = getActivity(); + if (activity != null) { + InputMethodManager imm = (InputMethodManager) activity + .getSystemService(Context.INPUT_METHOD_SERVICE); + if (imm != null) { + imm.hideSoftInputFromWindow(mMainView.getApplicationWindowToken(), 0); + } + } + } + }); + } @Override public void onSaveInstanceState(Bundle outState) { outState.putLong(KEY_PHOTO_RAW_CONTACT_ID, mPhotoRawContactId);