原因是我们获取Intent的数据时会在onResume中获取!
锁频后解锁时发出的Intent和之前跳转过来的是同一个!所以编辑数据不会保留会去INTENT中的数据!
解决方案一:
比较方便一点的!
在onPause中把Intent里的数据改变比如
Intent intent = getIntent(); String tel =mEditText.getText().toString(); Log.e("Dean", "onPause mEditText.getText()"+abc); setIntent(intent.putExtra("tel", abc));
对应的Uri 的取值是一样的不过Uri可能需要重新NEW一个Intent而不是在原来的基础上改!
解决方案二:
GOOLGE源码里的解决方法:
直接贴代码了!
onCreate: final Intent intent = getIntent(); intent.putExtra(EXTRA_IGNORE_STATE, true); if (!resolveIntent() && icicle != null) { super.onRestoreInstanceState(icicle); } onResume: Activity parent = getParent(); // See if we were invoked with a DIAL intent. If we were, fill in the // appropriate digits in the dialer field. if (parent != null && parent instanceof DialtactsActivity) { Uri dialUri = ((DialerPhoneActivity) parent).getAndClearDialUri(); if (dialUri != null) { resolveIntent(); } } @Override protected void onNewIntent(Intent newIntent) { Log.i(TAG, "onNewIntent: intent=" + newIntent); // setIntent(newIntent); resolveIntent(); setupDialUri(newIntent); } private void setupDialUri(Intent intent) { mDialUri = intent.getData(); } /** * Retrieves the uri stored in {@link #setupDialUri(Intent)}. This uri * originally came from a dial intent received by this activity. The stored * uri will then be cleared after after this method returns. * * @return The stored uri */ public Uri getAndClearDialUri() { Uri dialUri = mDialUri; mDialUri = null; return dialUri; } private boolean resolveIntent() { boolean ignoreState = false; // Find the proper intent final Intent intent; if (isChild()) { intent = getParent().getIntent(); ignoreState = intent.getBooleanExtra(EXTRA_IGNORE_STATE, false); } else { intent = getIntent(); } Log.i(TAG, "resolveIntent: intent=" + intent); // Resolve the intent final String action = intent.getAction(); if (Intent.ACTION_DIAL.equals(action) || Intent.ACTION_VIEW.equals(action)) { // see if we are "adding a call" from the InCallScreen; false by // default. Uri uri = intent.getData(); if (uri != null) { if ("tel".equals(uri.getScheme())) { // Put the requested number into the input area String data = uri.getSchemeSpecificPart(); mDigits.setText(data); mDigits.selectAll(); mDigits.setBackgroundDrawable(mDigitsBackground); } else { // String type = intent.getType(); // if (People.CONTENT_ITEM_TYPE.equals(type) // || Phones.CONTENT_ITEM_TYPE.equals(type)) { // // Query the phone number // Cursor c = getContentResolver().query(intent.getData(), // new String[] {PhonesColumns.NUMBER}, null, null, null); // if (c != null) { // if (c.moveToFirst()) { // // Put the number into the input area // setFormattedDigits(c.getString(0)); // } // c.close(); // } // } } } } return ignoreState; }