I tried HapticGenerator audio effect introduced in the API level 31.
The code is very simple:
if (HapticGenerator.isAvailable()) {
val sessionId = mediaPlayer.audioSessionId
val effect = HapticGenerator.create(sessionId)
effect.enabled = isEnabled
}
But it does not work, there is no effect at all.
Can anyone explain how it actually should work? Thanks!
P.S. my device is Samsung s22.
Related
I recently used this sample of great TensorFlow lite in android.
I can use this project correctly, but I want to estimate poses on single images too (not just in real time mode). so I tried to reach my goal! but unfortunately I couldn't! and those disappointing codes are here:
private fun runOnSimpleImage() {
val detector = MoveNet.create(this, device, ModelType.Lightning)
detector.let { detector ->
simpleDetector = detector
}
simpleDetector?.estimatePoses(templateBitmap)?.let {persons->
VisualizationUtils.drawBodyKeypoints(
templateBitmap,
persons, false
)
}
showOutputBitmap(templateBitmap)
}
Also I search it and found this. but I couldn't solve my problem yet.
and my result is something like this:
Fortunately my code is not wrong! and it works correctly. and you can use it!
The problem was in method that I used to convert my drawable image to Bitmap.
I used to use these codes:
val drawable = ResourcesCompat.getDrawable(resources, R.drawable.resized,theme)
templateBitmap = (drawable as BitmapDrawable).bitmap
But when I changed those to something like this:
templateBitmap = BitmapFactory.decodeResource(resources,R.drawable.resized)
my problem solved.
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
}
For iOS I am using app.ios.window.safeAreaInsets to discover the safe insets in NativeScript.
Similarly, I would like to discover the safe insets for Android phones, so I can properly handle Android devices that have a soft navigation for example or newer Android phones that have a notch as well (for example the OnePlus 6).
I see in the tns-platform-declarations that for SDK levels 20+ there is the class android.view.WindowInsets which has methods like getSystemWindowInsetTop() and getSystemWindowInsetBottom(), which seems to be exactly what I need.
I am struggling however to call those methods and was wondering whether anyone could advise on how to proceed.
So far I found that the decorView has a method onApplyWindowInsets(), but as far as I can see I already need to pass that one an instance of android.view.WindowInsets which as far as I can tell is what I am after.
This is what I have so far:
if (app.android && device.sdkVersion >= '20') {
const window = app.android.startActivity.getWindow();
const decorView = window.getDecorView();
//decorView.onApplyWindowInsets();
}
Thanks for any pointers!
This snippet works for me, at least for detecting the bigger height of a status bar with notch.
let androidStatusBarHeight = 0;
const context = application.android.context;
const metrics = new android.util.DisplayMetrics();
context.getSystemService(android.content.Context.WINDOW_SERVICE).getDefaultDisplay().getRealMetrics(metrics);
console.log(metrics.density);
const resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
if(resourceId > 0) {
console.log(context.getResources().getDimensionPixelSize(resourceId));
androidStatusBarHeight = context.getResources().getDimensionPixelSize(resourceId) / metrics.density;
} else {
androidStatusBarHeight = 24;
}
return androidStatusBarHeight;
I have a sencha application which runs fine on Jellybean version. When I tried to run it in Kitkat version, soft keyboard hiding my textfield. To sort out that, I gave android:windowSoftInputMode= "stateVisible|adjustResize" in AndroidManifest file. Though it got sorted, that induced the following bug as shown in the screenshot. View cuts in to halves. Is there any solution for this? Would be really thankful if anybody can help me in that. Thanks!
We can resolve this bug using javascript, by getting the offset of the element through id and scroll it to that particular offset dynamically
var panelHeight = Ext.get('panelId').getHeight();
console.log('offset of panel height scrollToFocussedElement : '+panelHeight)
var offset = document.getElementById('elementId').offsetTop;
if (navigator.userAgent.toLowerCase().match('android')) {
offset = offset + panelHeight;
}
console.log('offset in scrollToFocussedElement : '+offset);
Ext.getCmp('viewId').getScrollable().getScroller().scrollTo(0, offset);
I'm novice at Xamarin and I'm trying to use ShinobiCharts in Xamarin.Android to show candlestick data on it.
Code from .axml:
<fragment
class="com.shinobicontrols.charts.ChartFragment"
android:id="#+id/chart"
android:layout_width="match_parent"
android:layout_height="match_parent" />
This is fragment where should be shown chart.
var chartFragment = (ChartFragment)FragmentManager.FindFragmentById(Resource.Id.chart);
var chart = chartFragment.ShinobiChart;
chart.SetLicenseKey("license_key");
chart.AddXAxis(new DateTimeAxis
{
GesturePanningEnabled = true,
GestureZoomingEnabled = true
});
chart.AddYAxis(new NumberAxis
{
GesturePanningEnabled = true,
GestureZoomingEnabled = true
});
var dataPoints =
quotes.Select(
quoteCandle =>
new MultiValueDataPoint(DateUtils.ConvertToJavaDate(TimeStamp.UnixToDate(quoteCandle.Timestamp)),
(double) quoteCandle.Low, (double) quoteCandle.High,
(double) quoteCandle.Open, (double) quoteCandle.Close)).ToList();
var series = new OHLCSeries { DataAdapter = new SimpleDataAdapter() };
series.DataAdapter.AddAll(dataPoints);
chart.AddSeries(series);
chart.XAxis.Style.GridlineStyle.GridlinesShown = true;
chart.YAxis.Style.GridlineStyle.GridlinesShown = true;
chart.RedrawChart();
This is code of creating ShinobiCharts.
The problem is that added series are not shown in chart. Style changed, but there are no series. What do I do wrong? I hope anyone can help.
Sorry for question, Candlestickes are not available for trial version of ShinobiControls, only for premium version.
As sammyd said, CandlestickSeries are available in the trial version of ShinobiCharts for Android (as are all the other premium features). Have you managed to get the CandlestickChart sample running? The sample is included in the download bundle.
On the face of it your code looks fine (without seeing the rest of it) but there are a couple of things I'd recommend checking:
Have you replaced the string license_key with the trial license key we would have emailed you when you downloaded the bundle? The trial license key is a a really long string of characters and digits.
Is your data coming in as expected and does it make sense (e.g. are your low values less than your open values etc.)?
I'm not sure it'll make much difference, as they're pretty much interchangeable, but you're actually creating an OHLCSeries in code but mention a CandlestickSeries
Have you set the series' style object in a way that would stop it from showing i.e. have you set it to be transparent in colour?
Are you getting an actual error, and if so what message is being logged?
Hopefully the above will help you get your candlestick chart up and running!
Edit:
If you're using the Android Emulator, your AVD needs to have GPU emulation turned on (as we use OpenGL ES 2.0 for rendering the charts). There's more information on using the emulator with OpenGL on the Android developer site.
Disclaimer: I work for ShinobiControls