开发者

android pendingIntent cached on multiple calls to ACTION_EDIT contact after pressing Home Button

开发者 https://www.devze.com 2023-04-02 10:10 出处:网络
I´ve got a HOMESCREEN WIDGET with a BUTTON. Here´s the action added to teh button: Intent editContact = new Intent(Intent.ACTION_EDIT, ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_U

I´ve got a HOMESCREEN WIDGET with a BUTTON. Here´s the action added to teh button:

Intent editContact = new Intent(Intent.ACTION_EDIT, ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, Long.valueOf(contactID)));

editContact.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY|Intent.FLAG_ACTIVITY_NEW_TASK);

PendingIntent pendingEditContact = PendingIntent.getActivity(rcvContext, appWidgetID, editContact, PendingIntent.FLAG_UPDATE_CURRENT);

Whenever the internal android activity for editing contact is left by either editing the contact or pressing the back key without editing, everything works fine and the activity is removed from t开发者_StackOverflow社区he stack. Relaunching the activity from another widget correctly displays corresponding contact data to edit.

If the contact is not edited and left by pressing the Home Button of the Android device, relaunching a different contact from another widget again replaces the previous contact data. Unfortunately, this happens for the second launch only. Any attempt greater than 2 (i.e. pressing the Home Button again without editing the contact) results in the activity holding the previous contact data to edit. Apparently, pending intents are cached. That is why PendingIntent.FLAG_UPDATE_CURRENT should update the intent as to which contact to edit but to no avail :-(

I also had a got at the following:

PENDING INTENT:

PendingIntent.FLAG_CANCEL_CURRENT;

ACTIVITY:

editContact.putExtra("random", System.currentTimeMillis());

I´d like your advice on solving this issue. Thanks a lot folks!

0

精彩评论

暂无评论...
验证码 换一张
取 消