Voice command for screen unlock android - java

I want to use voice command to screen unlock an android phone.
I have tried the voice recognition sample code from android, but how do i integrate it to achieve this feature?
I have some doubts,
1) would i have to use service for this feature?
2) when the phone screen is locked, can it have access to internet? (because google voice is using internet)
3) I have looked through PowerManager class, but using which method can i invoke my voiceReconigtion activity when i pressed the Power button? (phone is in sleep,locked mode)
Any guide or solution/feedback is much appreciated!
Thank You

I am almost positive you'll have to run this in a service, as it seems that it would be destroyed as soon as it's out of focus and the GC needs allocations...
As far as the waking from sleep, I believe this is the right direction.
Best of luck.

Related

Stop app from pausing music (from Spotify etc.) on launch?

I'm busy making a template for a general UI which I can use in multiple apps, and I discovered that my app pauses music playing in the background whenever it is launched - most likely due to it having its own start-up sound in the form of a .mp4 that is played as a splash screen.
Is there a way of preventing my app prioritizing its own volume above others or making it mute its own volume when sound is already being played by the device?
PS: If using .mp4 is not general practice for splash screens, I admit, I'm learning as I go - if anyone can correct me on the proper or most optimized solution for making a sound + video happen while not interfering with external apps' sound, that would be much appreciated. Thanks :)
The only way that I know of is disabling the sound for the app that is causing the issue. Most apps have a setting to turn off sound. I don't think you can disable this for every app at once, otherwise when someone calls, you would have to manually turn off the music before answering, "hello".
You can also go into your app settings and "stop notifications" which might help.
I've been using Spotify on my s10 for some times. I also faced the same issue. I found a post why Spotify keeps stopping, and I cleared cache and turned off power saving mode on my device. You can try logging out from other devices which is also helpful

How do I stop hogging the microphone

TL;DR: My app is hogging the user's microphone. Can I turn it off automatically whenever another app needs to use the mic?
I have an Android app that has some really cool microphone functionality, similar to Amazon Alexa, that stays on all the time in a background service. The problem is, my app hogs the users' microphone, making it unusable:
However, this is terrible application behavior on my behalf, and I want to do my best to avoid it. Is it possible to be notified when another application requests to use the microphone, so that I can automatically stop my service?
PS: I am using the Pocketsphinx library for continuous background voice recognition.
This is tricky, as I'm not a ware of any API for this. This surely will require system-level APIs to work like an "Ok Google" type of thing.
A viable option would be (from https://stackoverflow.com/a/43623308/603270) to run a Job at regular intervals, checking for foreground apps using android.permission.PACKAGE_USAGE_STATS.
This might suffice. But you could also add things regarding phone calls (how to detect phone call broadcast receiver in android) using android.intent.action.PHONE_STATE or media playback (via Receiver or maybe even MediaPlayer directly).
If you're really wanting to get this thing working, an alternative would be to get an array list of all installed apps on the system and which ones require permission to use the mic or not, then use an accessibility service to monitor the users screen if an app the user just opened requires the mic (which you'll know from the array you just grabbed). From there, disable the mic in your app if their app needs the mic. The background service can then check in intervals of, say, two minutes, to see if the app that required the mic is still open. This is really inefficient. But if you don't care, then this might be a good option.
There is no standard way to inform another app that you want access to the microphone (so that they release the resources and let you access it). You could however send a broadcast to all other apps ("requesting the microphone"), but the other apps would have to implement this feature (and very few or zero developers will do this).
I would recommend you to simply inform the user that the microphone is currently not available, because you can't do anything else.

Ideas for my app that runs in the background

I'm developing an app that runs in the background that essentially snaps a front facing photo every time the phone is successfully/unsuccessfully unlocked. This isn't an original idea, but I'm developing it as a final project for my college android programming course, with no intent to sell this app. I have a general idea how I am going to go about this via some research but I keep running across a problem.
I know that it is hard and bad practice to run an app continuously in the background, so the idea is you put the app to sleep and set an alarm. My problem is that if the would be phone-snooper were to get really lucky, they could access the phone in between the alarms, and the owner of the phone would never know. I talked with my professor, and he proposed a couple ideas, but we could not come up with a definite solution, so I'm asking opinions here. Any idea how to subvert this dilemma? Thanks a ton.
Your approach is probably not appropriate for the problem. You can't "time" unpredictable events (like someone attempting to unlock a phone). Or else it's not clear how you are setting the alarm.
You should change the approach to an event-based approach.
Either provide a service for a lock-screen app so that it can use your code to capture a pic by sending login attempt events to it. You write that and provide an SDK/API.
Or else create your own lock screen app with your feature:
https://stackoverflow.com/questions/10864300/create-a-lock-screen-of-my-own

Start video chat without user interaction - Android

I am a total noob on this site so please be patient. I am trying to initiate a Video Chat/Call without any user interaction or confirmation.
I found this:
Uri imUri = new Uri.Builder().scheme("xmpp").authority("gtalk").query("call;type=video").appendPath(email).build();
Intent IM = new Intent(Intent.ACTION_SENDTO);
IM.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
IM.setData(imUri);
startActivity(IM);
from here: https://stackoverflow.com/a/8024626/1184256
This gets me very close, but I then have to click an "Invite" button to continue. Is there a way I can emulate a KeyEvent to click this button or skip the popup window entirely with root access?
I don't even necessarily need to use Google Video Chat if someone has found a different way to initiate a Video call to a certain contact via Skype, Vtok,Fringe, ooVoo or whatever without user interaction.
I have also found OpenTok which after building a sample server and client on my site I have found that it works on desktop browsers but not in Android browsers. Please don't steal/use my apiKey or sessionId.
I have also found libjingle which will allow me to use Google Talk's peer-to-peer voice and video chat. I am thinking this will be the way to go, but it means building a video chat app from the ground up and wrapping it around these libraries... yeah. Anybody done this already?
I know this is essentially a duplicate thread, but I have searched for days and days for an answer and this is the closest I have come to getting this done.
BTW the reason I need this without user interaction is for a Telepresence robot, thus there won't be anybody actually holding/using the phone when I initiate this call.
Please HELP!
You'd have to actually change the built in android app (Talk?) that receives this intent to automatically accept these types of intents. There's no way to do it from a standalone app for security reasons.
I don't think that live video streaming will work natively in Android Browsers, since they dont support WebRTC (Yet) and do not support flash. With that said, OpenTok has an Android SDK in beta that lets you stream live video from android phone to browser, another android phone, or even an iOS phone as long as everyone is connected to the same session. Like you said, this does not work over the browser and you would have to build a native app.

Closing application in Android - delay

I programmed a button into my android app that called the finish() method when I click it. But somehow it does not close until after a 5-6 second delay.
I am recording sensor values for a particular movement of the phone. The problem is when there is a delay after I close, it records those unnecessary values and the analysis is messed up.
So any idea why the UI takes so long to respond? I am very new to Android and I can't find this online. I don't do too much computation- as and when sensors change I record the value onto a file in the sdcard memory. Sometimes if I run the program for too long, it just crashes and I don't know why.
Please help! I would also like to know if there's a manual way to kill through the computer? something like Ctrl+C for DOS?
Is there a keyboard shortcut to close a running Android application?
There is no concept in Android of "close a running Android application".
The Esc key in the emulator behaves as the BACK button to (typically) close the current activity.
I have a button that I use to kill the application in my phone and that has a huge delay.
No, you don't.

Categories