I have an app (NFC Sniffer) which allows users to read NFC tags. When a user attempts to read a tag, 1 of 3 things happens:
Nothing, the tag was not brought close enough
Detected NFC, but fails to read card, in which case a notification tone is played.
Reads tag, in which case a different notification sound is played.
Lots of new users are confused about these notification sounds. I want my program to have a help screen, with buttons to play these two sounds.
But how do I locate and play these two notifications from my code?
You can get these sounds from the sources of the AOSP project and include them in your own app. The sounds are part of the NFC system service app:
https://android.googlesource.com/platform/packages/apps/Nfc/+/master/res/raw/
Btw. starting with Android 4.4, you can disable the sounds while your activity is in the foreground by using the reader mode API with the flag NfcAdapter.FLAG_READER_NO_PLATFORM_SOUNDS.
Related
how to make the telegram's sound notification like an alarm, so that whenever there is a new post in the channel the phone keeps beeping like an alarm.
One possible solution on the iOS would be to forward messages from the channel (that's not mine, but I am a member) to my phone via SMS, as you can set a constant alarm for SMSes on iPhone.
I do not really have any better ideas on how to do this, so I am open to any clues that you can come up with. Maybe some of you know if there is any other way to achieve the same result on ios, android, windows phone or computer.
Thanks
To set a custom notification sound for any app, do as follows:
Settings : General : Apps & Notifications : App info
Now scroll to the app that you want to customise. In this case, select Telegram by pressing it.
Select "App notifications". Now you can select a default notification, but more particularly, you can pick a group or contact from the list.
The default setting for importance is "medium: no sound". Press that and change it to "Urgent" or "High". Go back one screen. Now you can select the sound, by pressing "Sound". Pick a sound, or add a custom sound by pressing "+" at the top right.
If you want to record something, like a voicetag that says "Telegram from Tom", simply move a recording of that into the "music" folder on your phone, select it as above and when a message comes in from Tom, you'll hear the message played.
These steps were taken on Android 8 on an LG G6, but should be similar for other phones. For older versions of Android this feature may not be available. IOS? Sorry, none around here.
You can also do this in the Telegram app: Screenshots below.
The channel members would need to set a specific alarm sound for the channel. There is no way the sender of a message (not even a bot) could modify the sound of a notification.
We have a music app (mp3) developed in Xamarin (Native Android App) using MediaPlayer. There will be list of songs that should be played one after the other. After around 10 minutes or so, the player stops. Once the phone is unlocked, the Player starts playing the next track. Seems the Nougat Doze is somehow intervening the Player. If I manually disable Battery Optimization for my app, then there is no issue.
Is there any fix for this problem rather than having each user to manually change the 'Batter Optimization' option. I wonder how other apps like Spotify plays songs continuously without any setting changes. Please help!
Any process that contains a running foreground service will not be considered for Doze mode. This is what apps like Spotify and Google Play Music use. Consider creating a relevant foreground service - it will be shown in the notification screen while the foreground service is running, so a dummy service will stick out.
Another option is to request the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission and then launch an ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS intent, which will take the user to the Battery Optimization screen for your app. This is a less-than-stellar user experience but does not require the creation of a foreground service that you may not otherwise need.
I have a live streaming app where you can be recording for hours and when the user receives a text message or a phone call, the vibration is trnaslated into sound and rippling video on the streaming.
Is it possible to somehow programmatically disable all notifications or do I have to ask the user to do so by himself?
You cannot control notifications from other apps. There is indeed a solution for rooted devices.
'Standards' part in this guide says:
One of the unfortunate problems Android users face is that there is no
centralized control for how notifications work. This means that if
there is an application prompting you with a notification, short of
uninstalling the application, there isn’t much you can do. Starting in
Android 4.1, users received a buried binary setting to 'Turn off
notifications’ for a specific app.
No, unfortunately not. Perhaps on rooted devices, but ¯_(ツ)_/¯. Best way seems to navigate the user to the related setting to disable all notifications, as you have also mentioned.
I use NFC to send text records from my app on device Nr.1 to my app on device Nr.2. Then the device is in touch, on both devices popup "touch to beam" UI. If I touch and beam message on device Nr.1 (sending part ot the pair) - message sent, everything working is just fine. But if I touch "touch to beam" UI on device Nr.2 (which should receive message) - then my app on device Nr. 1 is reloaded. Logcat is show nothing wrong, no errors. Seems, is that case app get some kind of empty NFC message? But why it's just do nothing on that? Why reload? I'm using ForegroundDispatch, create "text/plain" filters programatically, without manifest.
How I can handle this situation, then the users press wrong side of "touch to beam" UI??
If you do not set up Android Beam in your app, Android's default behavior upon beaming is to instruct the other device to either open that same app (first activity that filters for MAIN/LAUNCHER intents of an app with the same package name as the app on the source device), or if your app is not installed, open the Play Store listing. This is done by sending an AAR (+ a Play Store link?) over Beam.
So in your case, clicking the Beam UI on device 2 causes the AAR to be sent to device 1. As a result, your app will be (re-)opened on device 1. In order to overcome this, you can do the following:
Enable foreground dispatch for the activity on device 1, so that the received NDEF message is immediately processed by your app. I'm not sure if this collides with the Beam UI though.
Change the NDEF message sent by device 2 to something that does not contain an AAR using the Beam API.
I am writing a android app which is supposed to play back a audio file when a call is in progress coming from a specific number .. I tried many approaches.. but all went in vein
Separate Thread
Listener on Telephone service
starting a service in parallel
can any one please help me how to proceed regarding this ?
Update :
I am able to play a mp3 file on call recieve and i am able to play it load on speaker.. but how ever loud i play the calling party is not able to listen to it.... is there anyway i can push the speaker stream to call stream
From the api doc here
Note: You can play back the audio data only to the standard output
device. Currently, that is the mobile device speaker or a Bluetooth
headset. You cannot play sound files in the conversation audio during
a call.
So from this and lots of other so answers we can conclude that we can not play an audio during a call process.
But a long time ago from a personal experience with a handset I got a result where the audiotrack was playing while there was a call established and both the voices were heard at the same time. So I think this depends on handsets if it allows it then you can play.
You can try another thing experimentally. play the audio using a different route ( speakerphone or bluetooth).
Another option is to build your custom android build