Futter :- Start vibrating or ringing phone continuously after sending specific notification - android

When I triggered specific type of notification to the specific group of user then their phone will start vibrating or ringing phone continuously until user not stop from the App.
Can anyone suggest how can I make possible? or Any packages which useful in terminate state and start vibrating in all state?
Thank You.

Please provide snippets code over here. Might be possible you have initialise your notification class in build method instead of initState method.
#override
void initState() {
super.initState();
NotificationHandler().initializeFcmNotification();
}

Related

Is it possible to detect a Whatsapp voice call ended in Android?

I would like to listen when Whatsapp voice call ended.
If the app was granted to access notification listener, I can detect an incoming WhatsApp call by parsing notification data but there are no data when a call ended.
So is there any solutions for this case? Thank you.
You can also detect if the call is ongoing... because the notification will be posted to the listener every second ( Because the call duration info in notification changes
every second ) until the call ends. Just start a timer process to detect the last time a WhatsApp call notification was detected , and if the time is greater than 3 seconds, you can declare that as an ending of a call and run your code there.

Detect incoming outgoing or ringing calls while the app is closed or open

As we all know Broadcast receiver is not working anymore, kindly suggest me a better way to get this done.
Reccelly, I had used firebase to listen to event call incomming. Android system don't kill firebase service when it run in background. Now, I only know this way.

Android: How to start activity when phone is sleeping, similar to Viber incomming call activity

I am developing an app and this app needs to give a clear indication to the user when some event happens.
Only thing I could do until now is giving a notification in the notification area. But, I need to give a more visible notification, similar to the behavior when phone is ringing in an incoming call.
As I can understand, the reason why android is only allowing apps to give a notification is to prevent apps from disturbing the user. But, this app I am developing plays a vital role in the job of the user, so I don't think it is inappropriate to give a such strong notification.
I know it should be doable since apps like Viber can start an activity similar to a incoming phone call, even when the device is sleeping.
Does anyone know how to get this done?
Register a broadcast receiver, and add a custom action to it say CustomAction.Instead of showing notification, throw a broadcast and add CustomAction via intent filter.
Now in the onReceive method of broadcast listener, check
if(intent.getAction.equals("CustomAction"))Intent i = new Intent(context, YourActivity);
context.startActivity(i);
Sorry for not a formatted answer, I'm driving, will update it later for more clarification.
Update
Register broadcast receiver in a sticky service. So that service can be started automatically if killed and register broadcast register again.
Don't forget to unregister broadcast receiver in onDestroy() method of service and also in YourActivity when you purpose is resolved.
Just adding a sticky service (which does nothing) fixed the issue. Adding the service prevented the process getting killed when user exits the app and removes it from recent app list.
Because of the service, the app process is running even when a no UI is visible. In this state, if an activity is shown from the GCM service, it gets shown.
You can trigger a broascast as Vinay mentioned. If it still does not work, try using wake-locks. These wake-locks help in waking the device when it is in sleep mode. It will act like force wake and after calling wake-locks, you can perform your actions.
Hope it helped..
Thanks.

Kill app on incoming phone call

Hopefully an easy one for someone, but causing me problems.
I have an app that loops sound files. I have no code in onPause as I want the app to continue playing music in the background.
I now need the app to close if an incoming call is received.
I can add code to onPause and close the activity and stop the mediaplayer. However this stops the app if any app is launched.
How can I detect an incoming call to check for inside onPause?
To detect the incoming call, we register a BroadcastReceiver for the
action android.intent.action.PHONE_STATE. This will be broadcasted
when there is a change in phone state. The receiving intent will have
an extra string variable TelephonyManager.EXTRA_STATE which describes
the phone state. If this state is TelephonyManager.EXTRA_STATE_RINGING
then there will be another extra string variable
TelephonyManager.EXTRA_INCOMING_NUMBER. This variable contains the
incoming phone number. Note that this variable will not be present
when the state is not TelephonyManager.EXTRA_STATE_RINGING.
source : http://www.androiddevblog.net/android/detecting-incoming-and-outgoing-calls-in-android
basically, once you register a broadcast receiver you can listen for the broadcast notification you are interested in your phone, and then act accordingly.
You do not have to. Android takes care of it pausing your app - you have to use telephony manager to determine whether to stop your aplication or not. Proper way would be to handle this in onPause() method

android automatic application restart if device is in homescreen and idle for a period of time

I'm writing an app that will be used in public transportation and I have a special requirement for it. I need the app to auto restart/bring to front somehow if all the following conditions are met:
-the user presses the back key or the home key and the app is minimized
-a period of time has passed since the device is idle
In conclusion I'd like to know what should I use, broadcast receivers or background services.
Code snippets or examples would be appreciated :) Thank you !
You should register a BroadcastReceiver for screen_off action and on it's onReceive() method unlock the screen if required and launch your application.

Categories

Resources