Feed Buzzard
  • General
  • Tech
  • World Tech
  • World Tech Code
  • Wearable Tech
  • Pokemon
  • About Us
    • Terms & Conditions
    • Privacy Policy
  • Contact
No Result
View All Result
  • General
  • Tech
  • World Tech
  • World Tech Code
  • Wearable Tech
  • Pokemon
  • About Us
    • Terms & Conditions
    • Privacy Policy
  • Contact
No Result
View All Result
Feed Buzzard
No Result
View All Result
Home World Tech

Devices with Android + MIUI and setCustomSelectionActionModeCallback –

Gordon James by Gordon James
January 8, 2021
in World Tech
0
0
SHARES
5
VIEWS
Share on FacebookShare on Twitter

Development issue/problem:

I’m trying to create a custom menu, but that doesn’t work on a device with MIUI rom and Android 6. The result is a general menu with all items copied and selected. It works perfectly on other pure Android devices and simulators.

Code:

textViewTop.setCustomSelectionActionModeCallback(new android.view.ActionMode.Callback() {
@General Boolean Menu
onCareActionMode(android.view.ActionMode, menu) {

Log.d(LOG_TAG, onCreateActionMode) ;

return where;
}

@General Boolean menu
onPrereActionMode (Action mode, menu) {
Log.d(LOG_TAG, onPrereActionMode);
menu.clear() ;

int quote_quick = R.drawable.ic_desktop_mac_black_24dp ;
int quote_add = R.drawable.ic_computer_black_24dp ;
int copy = R.drawable.ic_devices_other_black_24dp ;

menu.add(Menu.NONE, QUOTE_START, 3, ).setIcon(quote_quick).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
menu.add(Menu.NONE, QUOTE_ADD, 2, ).setIcon(quote_add).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
menu.add(Menu.NONE, CUSTOM, 1, ).setIcon(copy).setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
return false;
}.

General Boolean
onActionItemClicked(ActionMode, MenuItem item) {
returns false;
}

@Override public void
toDestroyActionMode {

}
});

How can I solve this problem?

Solution 1:

A few thoughts. What happens if you take an item from the Recovery options menu and change it?

Here’s how:

public boolean onCreateOptionsMenu(final menu) {
getSupportMenuInflater().inflate(R.menu.main, menu);
new Handler().post( -> {
final View menuItemView = findViewById(R.id.menu_action_item);
.
}
}

Solution 2:

So I’ve found an alternative, but it only makes sense if it absolutely has to work on MIUI devices. It’s usually a little uncomfortable:

I noticed that the Wikipedia application has custom actions that work on the Xiaomi device, and after checking the code, I found that it works well when texts are selected in WebView.
You can mainly use WebView and replace OnActionModeStarted in your company.

Ancient:

String html = n +
n +
n +
n +
n +
n +
n +
n +
n +
n ;

Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState) ;
setContentView(R.layout.activity_main) ;

WebView webView = findViewById(R.id.web_view);
webView.setWebViewClient(new WebViewClient());
webView.loadData(html, text/html, UTF-8);
}.

@Override
public void onActionModeStart(mode)) {
super.onActionModeStart(mode);
menu = mode.getMenu();
menu.clear();
mode.getMenuInflater().inflate(R.menu.menu_text_select, menu);
}

Menu :

Results :

Solution 3:

According to https://developer.android.com/guide/topics/ui/menus#CAB, you must create a menu in OnCreateActionMode.

I did it this way (in Kotlin):

Fall actionModeCallbackA = object : ActionMode.callback {
override fun onActionItemClicked(mode: ActionMode?, p1: MenuItem?): Boolean {
Log.wtf(ACTIEMODUS, onActionItemClicked)
actionModeB = startActionMode(actionModeCallbackB)
return true
}.

Skip the fun onCheatActionMode?, Menu?: Boolean {
Log.wtf(ACTION MODE, onCreateActionMode)
fall inflater = mode ?.getMenuInflater()
inflater ?.inflate(R.menu.context_menu, menu)
return true
}.

Skip the fun to OwnActionMode(p0: ActionMode?, p1: Menu?): Boolean {
Log.wtf(ACTION MODE, onPrepareActionMode)
returns false
}

Replace the fun in destruction mode (p0: ActionMode?) {
Log.wtf(ACTION MODE, onDestroyActionMode)
actionModeA = null
}
}.

Solution 4:

I had a similar problem, maybe my solution will help someone. I had to create a view consisting of several EditTexts horizontally side by side, and add the ability to paste text (one letter of text in an EditText)
I used the ActionMode.Callback approach, and it worked well, except on Xiaomi devices. The solution for the Xiaomi devices was to use OnLongClickListener when editing text and to create a PopupMenu when a long click occurs:

editText.setOnLongClickListener(v -> {
PopupMenu menu = new PopupMenu(context,v);
MenuInflater inflater = menu.getMenuInflater();
inflater.inflate(R.menu.paste_menu_item, menu.getMenu()));
menu.setOnMenuItemClickListener(item -> {
pasteText();//een custom function to process the selected action
return false;
});
menu.show();
return true;
})

Good luck!

Related Tags:

mi 10 features,miui 11,latest launch of redmi note series,miui 10 update download,miui 12 release date,miui 13,miui 10.3 3,what is miui forum,how long does xiaomi support their phones,miui phones,miui system,is miui open source,used com miui home,miui 7

Total
0
Shares
Share 0
Tweet 0
Pin it 0
Share 0
Gordon James

Gordon James

James Gordon is a content manager for the website Feedbuzzard. He loves spending time in nature, and his favorite pastime is watching dogs play. He also enjoys watching sunsets, as the colors are always so soothing to him. James loves learning about new technology, and he is excited to be working on a website that covers this topic.

Related Posts

Blockchain Conference in Poland Showcases New Solutions to Problems in Enterprise Logistics
World Tech

Blockchain Conference in Poland Showcases New Solutions to Problems in Enterprise Logistics

December 15, 2022
World Tech

Rockstar Games Brings GTA to The Metaverse

October 20, 2022
World Tech

Ways Technology Is Changing The World Of Education

September 21, 2022
Next Post

How To Stop Installation of Multiple Slice APK In Android Studio 2.3 –

Problems In Your Air Conditioner- Fix It Like A Pro

Open .hlp files on Windows 10 (full guide)

No Result
View All Result

Recommended

Myths and Misconceptions About Joint Pain

Myths and Misconceptions About Joint Pain

18 mins ago
The Spider Veins Facts that Every Individual Ought to Know

The Spider Veins Facts that Every Individual Ought to Know

20 mins ago

5 Benefits of Telehealth That You Should Understand

10 hours ago
openai gpt3 dallmiddotdouglas mit technologyreview

Why GPT-3 is so Impressive – and Why it’s Also Worrying

18 hours ago

Categories

  • Fitness Trackers
  • General
  • Latest
  • Pokemon
  • Tech
  • Technology and Computing
  • Wearable Tech
  • World Tech
  • World Tech Code

Recent Posts

  • Myths and Misconceptions About Joint Pain January 30, 2023
  • The Spider Veins Facts that Every Individual Ought to Know January 30, 2023
  • 5 Benefits of Telehealth That You Should Understand January 30, 2023
  • Why GPT-3 is so Impressive – and Why it’s Also Worrying January 29, 2023

Categories

  • Fitness Trackers
  • General
  • Latest
  • Pokemon
  • Tech
  • Technology and Computing
  • Wearable Tech
  • World Tech
  • World Tech Code

© 2022 FeedBuzzard.com

No Result
View All Result
  • General
  • Tech
  • World Tech
  • World Tech Code
  • Wearable Tech
  • Pokemon
  • About Us
    • Terms & Conditions
    • Privacy Policy
  • Contact

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT