Disable default Android TV navigation sound effect Programmatically - android-tv

How to disable sound feedback effect in Android TV Programmatically. If i press navigation button while music service is playing, sound effect mutes music for second. Or may be there is some priorities for music service? Thanks in advance

You can change it via the AudioManager like this:
AudioManager audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
audioManager.adjustStreamVolume(AudioManager.STREAM_NOTIFICATION, AudioManager.ADJUST_LOWER, 0 /*or: AudioManager.FLAG_SHOW_UI*/);
To get the current notification volume, use
audioManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION)
Possible volume values are 0..7.
From API level 23, you can also use AudioManager.ADJUST_MUTE.

Related

Telegram Web Apps method Expand isn't working

I found that the method Expand of window.Telegram.WebApp object isn't working in the Telegram client for Windows and IOS on computers and tablets.
How to increase the size of Web Apps frame for those devices?
function buttonOn(){
// do something on btn click
}
let main_page = document.querySelector('#main_page');
if (main_page){
window.Telegram.WebApp.expand() //expand window after page loading
window.Telegram.WebApp.MainButton.onClick(buttonOn) //set func on main button click
window.Telegram.WebApp.MainButton.setParams({'text': 'Корзина'}) // set byn params
window.Telegram.WebApp.MainButton.show() //show telegram btn
}
Other button events
Remove the line from the function:
window.Telegram.WebApp.expand() //expand window after page loading
And call it in the beginning/at the top of your main javascript code. (The code that will start running once the user has clicked on the button)
Also, you can make your code a lot shorter by putting window.Telegram.WebApp in a variable like:
const tele = window.Telegram.WebApp; //Initializes the TELEGRAM BOT and
//Gets the user's Telegram ID from the Telegram API
tele.expand(); //Expands the app on the users' phone to 100% height
The reason is, probably, you are a bit incorrect in understanding what "expansion" is. This term could only be applied to mobile devices with OS such as Android or iOS. Web App is displayed there in such native component as BottomSheet with inserted WebView containing your web application. Initially, in mobile devices, application is being opened minimized (not expanded). To make it use maximum allowed height of screen, you could call expand() method. It must work through window.Telegram.WebApp.expand().
In desktop or web versions of Telegram, Web App is displayed in separate component which is not allowed to change its size.
You could probably find more useful information about viewport and expansion here, or use alternative libraries, such as twa-bridge or twa-sdk

Is it possible to use a xamarin form in place of a winform on a local display?

I have a number of console application that use winforms to gather simple input from the user (Do this and click "OK", Did this happen click "Yes" or "No" That kind of thing) There is a new requirement that we provide the option to gather the simple input from the user on a handheld device that runs Android.
I had hoped to convert our winforms to Xamarin forms that could be used either locally or be sent to the handheld device. This is not my area, really, so it may be that I am not looking at the problem in the right way.
The system running the console application is usually a laptop or maybe a desktop.
Does anyone have any advice?
You can use App Center Analytics Events Metrics to track user event.
Here is the document for Xamarin:
You can track your own custom events with up to twenty properties to
understand the interaction between your users and the app.
Analytics.TrackEvent("Video clicked", new Dictionary<string, string> {
{ "Category", "Music" },
{ "FileName", "favorite.avi"}
});

onGoing notification can still be removed by user, manually

i create an application and i want after click on specific button, a "Permanent Nofitication" show on notification bar.
i search for it and use these codes:
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.mipmap.ic_clip_board_service)
.setContentTitle(getResources().getString(R.string.notifTitle))
.setContentText(getResources().getString(R.string.notifText))
.setOngoing(true);
the ongoing method, prevent user to manually clear the notification.in my emulator(genymotion), everything is ok.but in my real Phone(Huawei G8) when i try to remove notificaiton, a pop-up menu appeared and say:
Not Recomended
removing ongoing notification may affect app stability.
the menu has already two buttons:cancel and Remove.and i can remove the notification.:(
i don't want user manually remove notification.
is the problem about my Phone or setOngoing(true) method?
thanks in advance...
Based off what I'm seeing for my app that behaves similarly, it appear Huawei phone's always allow clearing notifications and shutting down the app. My app even runs as a device administrator and it can still be cleared.

How to unlock iOS screen programmatically?

I'm currently exploring creating a jailbreak tweak. I want to unlock the phone screen. How is this done? What private API can be used to achieve this on iOS 7?
If we are talking about jailbreak then you can write a SpringBoard tweak that does this (iOS 7 only)
[[objc_getClass("SBBacklightController") sharedInstance] turnOnScreenFullyWithBacklightSource:0];
[[objc_getClass("SBLockScreenManager") sharedInstance] unlockUIFromSource:0 withOptions:nil];
Without passcode lock the code will turn on the screen and unlock the device. With passcode it will turn on the screen and request passcode.
I use Activator from Cydia to wake and unlock the device via SSH. It works on IOS 10.1.
activator send libactivator.system.homebutton
activator send libactivator.system.homebutton
lock command is here:
activator send libactivator.system.sleepbutton
Good Luck Have Fun :)
My solution comes in two parts but it could be better:
Power on screen by simulating a power button press with this code:
VNCSendHIDEvent(IOHIDEventCreateKeyboardEvent(kCFAllocatorDefault, mach_absolute_time(),
kHIDPage_Consumer, kHIDUsage_Csmr_Power, 1, 0)); // Power button down
VNCSendHIDEvent(IOHIDEventCreateKeyboardEvent(kCFAllocatorDefault, mach_absolute_time(),
kHIDPage_Consumer, kHIDUsage_Csmr_Power, 0, 0)); // Power button up
After 1, the screen will light up and then you can use SimulateTouch's stouch tool to simulate a swipe from the command line.
For 1 above, your code needs to have the com.apple.private.hid.client.event-dispatch entitlement.
For more, you can also investigate how Activator performs the Unlock screen listener.
Maybe not a direct solution.
You can use this tweak and library https://github.com/iolate/SimulateTouch to simulate a user swipe on the lockscreen to unlock the device.

BitmapButtonField Listener

In application I have implemented BitmapButtonField with image. On click of BitmapButton I have to integrate Facebook application. I searched for click event of bitmapButtonField but nothing is working.
Facebook = new BitmapButtonField(
Bitmap.getBitmapResource("facebook.png"));
Facebook.setMargin(0, 10, 0, 10);
horizontal_field.add(Facebook);
Facebook.setChangeListener(this);
If I'm testing this on touch listener phone. Its is working. If we have device without touch its not working.
Thanks
You have to pass the style property ButtonField.CONSUME_CLICK. So you can make the button clickable. you can use this constructor of the BitmapButtonField Class
BitmapButtonField( Bitmap normalState, Bitmap focusState, long style )
for exaple:
Facebook = new BitmapButtonField(Bitmap.getBitmapResource("facebook.png"),Bitmap.getBitmapResource("facebookFocusState.png"), ButtonField.CONSUME_CLICK);
That worked for me. on trackPad BlackBerry Phones

Resources