Android Question Hardware Notification Slider?

KL7000F

Member
Licensed User
Longtime User
Hi,
i use a private OnePlus 2. This has a hardware notification slider. Is there a way "to read" the position of such hardware slider?
I suspect that is not accessing OnePlus here to predetermined functions of Android.

The slider controls the interruptions. All notifications / priority / no alarm.

Thanks
Andy
 

KL7000F

Member
Licensed User
Longtime User
Hey Erel,

thanks a lot. I have found '"android.media.RINGER_MODE_CHANGED" receiver. But only two out of three slider-positions are give an result.
All Sounds:
1: (Intent) Intent { act=android.media.RINGER_MODE_CHANGED flg=0x24000010 cmp=de.ki.alertslider/.test$test_BR (has extras) }
2: Bundle[{android.media.EXTRA_RINGER_MODE=2}]
Only Priority:
1: (Intent) Intent { act=android.media.RINGER_MODE_CHANGED flg=0x24000010 cmp=de.ki.alertslider/.test$test_BR (has extras) }
2: Bundle[{android.media.EXTRA_RINGER_MODE=0}]
Silent give no result.

Now i have try to use a JavaObject, but i can't RunMethod "getCurrentInterruptionFilter"...

B4X:
Sub Button1_Click
    Dim jo As JavaObject
    Dim i As Int
    jo.InitializeStatic("android.service.notification.NotificationListenerService")
    'i = jo.GetField("INTERRUPTION_FILTER_ALL")
    i = jo.RunMethod("getCurrentInterruptionFilter", Null)
    Log(i)
End Sub
Dev/Android

Error:
B4X:
java.lang.IllegalArgumentException: Expected receiver of type android.service.notification.NotificationListenerService, but got java.lang.Class<android.service.notification.NotificationListenerService>


    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:130)
    at de.ki.alertslider.main._button1_click(main.java:344)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)


    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:77)
    at android.view.View.performClick(View.java:4786)
    at android.view.View$PerformClick.run(View.java:19902)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5290)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
java.lang.IllegalArgumentException: Expected receiver of type android.service.notification.NotificationListenerService, but got java.lang.Class<android.service.notification.NotificationListenerService>
If i try other initialize-methods, i will have other errors.

In Manifest i add this:
B4X:
AddApplicationText(
<service android:name="anywheresoftware.b4a.objects.NotificationListenerWrapper"
    android:label="NotiRead"
          android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
     <intent-filter>
         <action android:name="android.service.notification.NotificationListenerService" />
     </intent-filter>
</service>)
AddReceiverText(test, <intent-filter>
<action android:name="android.media.RINGER_MODE_CHANGED"/>
</intent-filter>)
This to add the app to the notification-listener:
B4X:
    Dim In As Intent
    In.Initialize("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS", "")
    StartActivity(In)
 
Upvote 0

KL7000F

Member
Licensed User
Longtime User
Thank you for your efforts.
But how am I supposed to read out the method "getCurrentInterruptionFilter"? This must be checked in my opinion the only way this slider.
 
Upvote 0
Top