how to stop ringtone in qt android
-
@gotronics said in how to stop ringtone in qt android:
ring.callMethod<void>("stopPreviousRingtone");
//ring.callObjectMethod("android/media/Ringtone","setVolume", "(F)V", 0);if(ring. is valid) is ok because it rings or the phone rings very well
the problem is to stop it after 2 seconds by the
the following functions are not workingring.callMethod<void>("stopPreviousRingtone");
ring.callMethod<void>("setStopPreviousRingtone", "(Z)V", true);
ring.callMethod<jboolean>("android/media/Ringtone","isPlaying", "(Z)V")
-
@gotronics
at what point does your code exactly fail?
hereif ( ring.isValid() )
?Also note that many methods require to be called from Android's UI thread (which Qt code doesn't by default!).
For this you can use QtAndroid::runOnAndroidThreadSync()But also its very likely that the console output (or LogCat) already gives some clues what is going wrong your case.
@raven-worx
thank you for the reply@gotronics said in how to stop ringtone in qt android:
ring.callMethod<void>("stopPreviousRingtone");
//ring.callObjectMethod("android/media/Ringtone","setVolume", "(F)V", 0);if(ring. is valid) is ok because it rings or the phone rings very well
the problem is to stop it after 2 seconds by the
the following functions are not workingring.callMethod<void>("stopPreviousRingtone");
ring.callMethod<void>("setStopPreviousRingtone", "(Z)V", true);
ring.callMethod<jboolean>("android/media/Ringtone","isPlaying", "(Z)V")
-
@gotronics
at what point does your code exactly fail?
hereif ( ring.isValid() )
?Also note that many methods require to be called from Android's UI thread (which Qt code doesn't by default!).
For this you can use QtAndroid::runOnAndroidThreadSync()But also its very likely that the console output (or LogCat) already gives some clues what is going wrong your case.
-
@gotronics
at what point does your code exactly fail?
hereif ( ring.isValid() )
?Also note that many methods require to be called from Android's UI thread (which Qt code doesn't by default!).
For this you can use QtAndroid::runOnAndroidThreadSync()But also its very likely that the console output (or LogCat) already gives some clues what is going wrong your case.
-
@gotronics
at what point does your code exactly fail?
hereif ( ring.isValid() )
?Also note that many methods require to be called from Android's UI thread (which Qt code doesn't by default!).
For this you can use QtAndroid::runOnAndroidThreadSync()But also its very likely that the console output (or LogCat) already gives some clues what is going wrong your case.
@raven-worx
sorry if you check again my code i corrected were i had initially commented
ring.callMethod<void>("play"); -
@raven-worx
sorry if you check again my code i corrected were i had initially commented
ring.callMethod<void>("play");@gotronics
the JNI signature for yourisPlaying
call is wrong. Should rather be()Z
(not(Z)V
)Beside that i do not see the methods
setStopPreviousRingtone
andstopPreviousRingtone
in the Ringtone class -
@gotronics
the JNI signature for yourisPlaying
call is wrong. Should rather be()Z
(not(Z)V
)Beside that i do not see the methods
setStopPreviousRingtone
andstopPreviousRingtone
in the Ringtone class@raven-worx
setStopPreviousRingtone and stopPreviousRingtone are from RingToneManager
so used incorrectly in RingTone class. I have corrected there and i can now stop the ringtone using this ring.call("stop", "()V");
and ring.callMethod<jboolean>("isPlaying", "()Z")) now working
thank you very much.i still have challenge on the following
QString str; QMessageBox::information(this, " Volume", str.setNum(ring.callMethod<jfloat>("getVolume", "()F")));
i am getting 0 even though the ringtone volume is way above 0 level
-
@gotronics
at what point does your code exactly fail?
hereif ( ring.isValid() )
?Also note that many methods require to be called from Android's UI thread (which Qt code doesn't by default!).
For this you can use QtAndroid::runOnAndroidThreadSync()But also its very likely that the console output (or LogCat) already gives some clues what is going wrong your case.
@raven-worx
setStopPreviousRingtone and stopPreviousRingtone are from RingToneManager
so used incorrectly in RingTone class. I have corrected there and i can now stop the ringtone using this ring.call("stop", "()V");
and ring.callMethod<jboolean>("isPlaying", "()Z")) now working
thank you very much.i still have challenge on the following
QString str;
QMessageBox::information(this, " Volume", str.setNum(ring.callMethod<jfloat>("getVolume", "()F")));
i am getting 0 even though the ringtone volume is way above 0 level -
@gotronics
at what point does your code exactly fail?
hereif ( ring.isValid() )
?Also note that many methods require to be called from Android's UI thread (which Qt code doesn't by default!).
For this you can use QtAndroid::runOnAndroidThreadSync()But also its very likely that the console output (or LogCat) already gives some clues what is going wrong your case.
i have been going through android api and discovered that getVolume() was introduced in API 28 its not working because i am using API19
thank you very much -
This post is deleted!