I am an Android developer and have noticed bad behavior on Samsung devices running Android 13 (One UI 5.0). I don't see this problem on Samsung devices running earlier OS version (tested Android 11 and Android 12). I don't see this issue on non-Samsung devices running Android 13 either. The issue faced is the dialogue appears full width in the screen. It will works fine in google pixel. The issue is only noticed in Samsung phones. The used code is :
if (m_dialog_idproof.isShowing()) {
m_dialog_idproof.dismiss();
}
}
m_dialog_idproof = new Dialog(MyPage_Activity.this);
m_dialog_idproof.requestWindowFeature(Window.FEATURE_NO_TITLE);
m_dialog_idproof.setCancelable(false);
LayoutInflater m_inflater = LayoutInflater.from(MyPage_Activity.this);
View m_view = m_inflater.inflate(R.layout.idproofcheck_popup, null);
ImageView close_EON = m_view.findViewById(R.id.close_privacy);
LiveButton submitEON = m_view.findViewById(R.id.uploadid);
TextView tv = m_view.findViewById(R.id.textid);
tv.setText("Dear " + name + "");
submitEON.setOnClickListener(v -> {
Intent intentidproof = new Intent(MyPage_Activity.this, UploadIDProof_Activity.class);
startActivity(intentidproof);
overridePendingTransition(R.anim.slide_up, R.anim.slide_out);
m_dialog_idproof.dismiss();
});
close_EON.setOnClickListener(v -> m_dialog_idproof.dismiss());
m_dialog_idproof.setContentView(m_view);
m_dialog_idproof.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
m_dialog_idproof.show();
Related
I have a view where a user enters a goal, a date to complete it by, and a confirmation checkbox. A user must enter all of this to move forwards. Thus, I have checks to see if any of the fields are empty. Here is the code for that. This code works.
private fun toggleInputRequiredError(
isErrorVisible: Boolean,
view: TextInputLayout,
errorText: String
) {
when (isErrorVisible) {
true -> {
view.error = errorText
}
else -> view.error = null
}
}
toggleInputRequiredError(
!state.isGoalChecked,
goalAffirmationCheckBoxErrorContainer,
getString(R.string.required_field)
).run {
if (!state.isGoalChecked) {
goalAffirmationCheckBox.isFocusable = true
goalAffirmationCheckBox.requestFocus()
goalAffirmationCheckBox.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED)
}
}
toggleInputRequiredError(
!state.isValidDateInput,
goalDateInputLayout,
getString(R.string.required_field)
).run {
if (!state.isValidDateInput) {
goalCompletionDateInput.isFocusable = true
goalCompletionDateInput.requestFocus()
goalCompletionDateInput.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED)
}
}
toggleInputRequiredError(
!state.isValidDescriptionInput,
goalDescriptionInputLayout,
getString(R.string.required_field)
).run {
if( !state.isValidDescriptionInput) {
goalDescriptionInput.isFocusable = true
goalDescriptionInput.requestFocus()
goalDescriptionInput.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED)
}
}
Now I have to enable accessibility for this view with also works, on most phones except for the latest Samsung phones. The desired behaviour are exemplified by the Pixel XL but also the Samsung S8. Here is an image to show this
On the newer Samsungs the sendAccessibilityEvent doesn't seem to actually focus on the view that needs to be addressed. Here is an image to show this behavior on the Samsung S10+ and Samsung Note 9.
I set the content description of these views in the XML. I noticed that the newer Samsung phones will read the "Required" text on the screen but not focus on it. This means that it ignores the content description in the XML. The last thing is that the view that needs to focusing seems not to experience the sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED) event
Let me know if you have any thoughts on how to address this or if you have any suggestions I can try
In the Samsung S10 device, I can't able set accessibility focus to the custom view. Then I have achieved based on the following code so can try this with your follow maybe it would be helpful.
val task = Runnable {
val mA11yManager = context.getSystemService(Context.ACCESSIBILITY_SERVICE) as AccessibilityManager
if (mA11yManager.isEnabled) {
// Equivalent to ACTION_ACCESSIBILITY_FOCUS
plus_chip_text?.performAccessibilityAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
// we fire selection events here not in View
plus_chip_text?.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED)
}
}
val worker: ScheduledExecutorService = newSingleThreadScheduledExecutor()
worker.schedule(task, 1, TimeUnit.SECONDS)
Sorry I know this is almost a year later, but we found a very similar issue on Samsung Talkback running Android 10. It would work fine on earlier versions of Android.
We found creating the following kotlin extension function seemed to work for all versions of Android, as well as working well for both Samsung Voice Assistant and Talkback.
Hope this is able to help anyone else facing a similar issue.
fun View?.requestAccessibilityFocus(): View? {
this?.performAccessibilityAction(ACTION_ACCESSIBILITY_FOCUS, null)
this?.sendAccessibilityEvent(TYPE_VIEW_SELECTED)
return this
}
I have Button where I want to set DrawableLeft. This code down below is working as intended for most of Android devices but for Huawei and Samsung it is not working and drawable has default color on screen.
That means icon.setTint(ContextCompat.getColor(app, R.color.colorTextDarkGrey)) is not working for some reason.
This app was tested on devices with API level 23 or higher. (Older versions are not supported). It was also tested on Android 6.0 and Android 7.1 and it worked.
Huawei phone is Android 8.0 and Samsung phone is Android 9.0
private fun setPrevButton(){
App.log("ButtonSetters: setPrevButtonVariant()")
val icon = app.resources.getDrawable(R.drawable.arrow_black_short_left, null)
icon.setTint(ContextCompat.getColor(app, R.color.colorTextDarkGrey))
backBtn.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null)
}
Please follow below code to solved this issue.
val unwrappedDrawable = AppCompatResources.getDrawable(context, R.drawable.my_drawable)
val wrappedDrawable = DrawableCompat.wrap(unwrappedDrawable!!)
DrawableCompat.setTint(wrappedDrawable, Color.RED)
I've got a real doozy here. When I click on spinners, open menu items, or open context menus on long-clicks I get the same Logcat message:
08-02 21:20:57.264: E/ViewRootImpl(31835): sendUserActionEvent() mView == null
The tag is ViewRootImpl, and the message is sendUserActionEvent() mView == null. I could not find anything helpful about this on the web. I searched through the Android sources and found some references to mView, but I could not find the file in which this log message is printed. For reference, I'm using a Samsung Galaxy S4 running 4.2.2, or API 17. The same message does NOT occur when debugging on a Nexus 7 running Android 4.3. Any ideas? Is this a Samsung-specific issue?
I also encuntered the same in S4. I've tested the app in Galaxy Grand , HTC , Sony Experia but got only in s4. You can ignore it as its not related to your app.
I solved this problem on my Galaxy S4 phone by replacing context.startActivity(addAccountIntent);
with startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT));
Same issue on a Galaxy Tab and on a Xperia S, after uninstall and install again it seems that disappear.
The code that suddenly appear to raise this problem is this:
public void unlockMainActivity() {
SharedPreferences prefs = getSharedPreferences("CALCULATOR_PREFS", 0);
boolean hasCode = prefs.getBoolean("HAS_CODE", false);
Context context = this.getApplicationContext();
Intent intent = null;
if (!hasCode) {
intent = new Intent(context, WellcomeActivity.class);
} else {
intent = new Intent(context, CalculatingActivity.class);
}
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
(context).startActivity(intent);
}
Even i face similar problem after I did some modification in code related to Cursor.
public boolean onContextItemSelected(MenuItem item)
{
AdapterContextMenuInfo info = (AdapterContextMenuInfo)item.getMenuInfo();
Cursor c = (Cursor)adapter.getItem(info.position);
long id = c.getLong(...);
String tempCity = c.getString(...);
//c.close();
...
}
After i commented out //c.close(); It is working fine.
Try out at your end and update
Initial setup is as... I have a list view in Fragment, and trying to delete and item from list via contextMenu.
This has to do with having two buttons with the same ID in two different Activities, sometimes Android Studio can't find, You just have to give your button a new ID and re Build the Project
It is an error on all Samsung devices, the solution is:
put this line in your activity declaration in Manifest.
android:configChanges="orientation|screenSize"
also when you start the activity you should do this:
Intent intent = new Intent(CurrentActivity.this, NextActivity.class);
intent.setType(Settings.ACTION_SYNC_SETTINGS);
CurrentActivity.this.startActivity(intent);
finish();
I used this to make an activity as fullscreen mode, but this question does not need the fullscreen code, but in all cases might someone need it you can refer to this question for the rest of the code:
How to make VideoView full screen
I have got a Toast Notification when clicking at some button.
This Toast Notification works fine on a Smartphone, but on a Tablet it only appears when the button is clicked for the first time - afterwards the Toast Notification doesn't show up (it does on a smartphone!)
What is the difference? (OS Versions 2.3 on Smartphone and 3.1 on Tablet - target is 2.3 though in the manifest)
//Display Custom Toast
if(mToast == null){
mToast = new Toast(getContext());
} else {
mToast.cancel();
}
ImageView imageView = (ImageView) layout.findViewById(R.id.toast_image);
imageView.setImageBitmap(aux.getArtwork(getContext()));
TextView tvTitle = (TextView) layout.findViewById(R.id.toast_title);
TextView tvArtist = (TextView) layout.findViewById(R.id.toast_artist);
TextView tvChannel = (TextView) layout.findViewById(R.id.toast_channel);
tvTitle.setText(aux.getTitle());
tvArtist.setText(aux.getArtist());
tvChannel.setText(aux.getFirstChannel().toString());
mToast.setDuration(Toast.LENGTH_SHORT);
mToast.setView(layout);
mToast.show();
This has nothing to do with the tablet. I have successfully implemented toast message on Sony S. I reckon you cross check your code and yea there will be a difference at times when you run from one platform to another. You can set the minimum sdk version to 2.3 and set the target platform to 3.1 to ensure the apps performance.
This thing baffle me...
I was checking my code, and decided to change the build target from 2.3 to 2.2 to make sure every 2.3 API that I use is wrapped in a nice android.os.Build.VERSION.SDK_INT check.
But somewhere I make a call to java.text.Normalizer.normalize() that does not check for the SDK version. Curious as why this wasn't found by QA, I started the app on a 2.2 phone in debug mode and it works fine!
The phone is a LG-P505R version 2.2.2.
So, why does this 2.2 phone can call some API that were added in 2.3?
The only logical explanation that I could think of is that the manufacturer has added this API to the Android stack.
[Update] More madness...
I tested this code on a 2.2. emulator and it works fine:
public class NormalizerTestActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final String s = "This \"é\" will become an \"e\"";
final TextView tv = (TextView) findViewById(R.id.tv);
final String temp = Normalizer.normalize(s, Normalizer.Form.NFD);
final Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
final String strNormalized = pattern.matcher(temp).replaceAll("");
tv.setText(strNormalized);
}
}
So for now my only guess is that it was made public in 2.3, but it was there all along...
Confirmed That java.text.Normalizer works perfectly in a vanilla API8 emulator. Just have to add lint error suppression to the code to get eclipse to compile.