jose luis gudino Active Member Licensed User Longtime User Oct 14, 2019 #1 Hi There is a function in which when you press the volume down button or increase the volume, this executes an event in a service that is running in the background? I plan to make a security application in which if the user presses the volume down button 5 times a notification will be generated Thanks in advance
Hi There is a function in which when you press the volume down button or increase the volume, this executes an event in a service that is running in the background? I plan to make a security application in which if the user presses the volume down button 5 times a notification will be generated Thanks in advance
DonManfred Expert Licensed User Longtime User Oct 14, 2019 #2 Try to setup a intentfilter Code: <receiver android:name="com.example.myproject.receivers.MyReceiver" > <intent-filter> <action android:name="android.media.VOLUME_CHANGED_ACTION" /> </intent-filter> </receiver> Or a broadcastreceiver Code: public class MyReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals("android.media.VOLUME_CHANGED_ACTION")) { Log.d("Music Stream", "has changed"); } } } Upvote 0
Try to setup a intentfilter Code: <receiver android:name="com.example.myproject.receivers.MyReceiver" > <intent-filter> <action android:name="android.media.VOLUME_CHANGED_ACTION" /> </intent-filter> </receiver> Or a broadcastreceiver Code: public class MyReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals("android.media.VOLUME_CHANGED_ACTION")) { Log.d("Music Stream", "has changed"); } } }