Mark M. | has entered the room |
Mark M. | turned on guest access |
Mar 20 | 4:00 PM |
Milan | has entered the room |
Mar 20 | 4:05 PM |
Mark M. |
hello, Milan!
|
Mark M. |
how can I help you today?
|
Milan |
hello Mark
|
Milan |
Notification is playing both sound and vibration. If I would like to silent it, how to do it>
|
Mark M. |
on Android 8.0+, set up your channel to not have a sound
|
Mark M. |
prior to that, do not configure a sound on the notification, and do not opt into the default sound
|
Milan |
but that is not an option
|
Mark M. |
I am sorry, but I do not understand what you mean
|
Milan |
I want to mute it when I hear ringing tone
|
Milan |
mAudioManager.adjustSuggestedStreamVolume(mAudioManager.ADJUST_MUTE, AudioManager.STREAM_NOTIFICATION, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
|
Milan |
something like this
|
Milan |
this only mutes sound, vibration is still there
|
Milan |
despite the flag
|
Mark M. |
then do not put a vibration pattern on the notification in the first place
|
Milan |
but I want to have it in first place
|
Mark M. |
I assume that you are referring to notifications that your app is raising
|
Milan |
I just want to mute everything occasionaly
|
Milan |
rught
|
Milan |
right
|
Mark M. |
on Android 8.0+, set up two different channels, one with and one without vibration, and use the channel that is appropriate at the time
|
Milan |
I would like to achieve similar behaviour as native diler
|
Milan |
dialer
|
Mar 20 | 4:10 PM |
Mark M. |
I do not know what the behavior is that you are seeking
|
Mark M. |
at the time you raise the notification, you have to decide whether it will vibrate or not
|
Milan |
hm, interesting approach. So you are suggesting that I have incoming call, notification is there, ringing and vibrating
|
Milan |
I see that Mark is calling me, I don't want to answer
|
Milan |
i just cancel that notification and create new one within silent channel?
|
Mark M. |
by the time you react, the notification ringtone and vibration pattern will have elapsed, iMHO
|
Milan |
and I will still have notification for incoming call, will be able to answer, but ringtone and vibration will not buzz me
|
Mark M. |
it already buzzed you
|
Milan |
it is ringtone notification, not the short one
|
Milan |
yep, but native does the same thing
|
Milan |
native dialer
|
Milan |
you receive incoming call
|
Milan |
you either press power, volume down, volume up, squeez the phone (pixel), vibration and ringtone are muted and incoming call notif is still there
|
Mark M. |
sorry, but other than by changing the notification, I do not know how to do what you are seeking
|
Mark M. |
there may be other solutions, but i do not know them
|
Milan |
ok, I am good with that solution, will try it
|
Milan |
another thing, any way to listen volume up and down hard keys?
|
Mark M. |
if you use the same notification ID, it should just modify the existing notification... though I have not tried that for changing the notification channel
|
Mar 20 | 4:15 PM |
Mark M. |
if your app is in the foreground, I think they result in KeyEvents
|
Milan |
bkg
|
Milan |
sorry, forgot to mention
|
Mark M. |
there might be broadcasts for that
|
Andre R. | has entered the room |
Mark M. |
Milan: let me take a question from Andre, and I'll return to you shortly
|
Mark M. |
Andre: hi! do you have a question?
|
Milan |
not sure, Romain Guy says it is not possible
|
Milan | |
Andre R. |
Good afternoon. I would like to know if I have to close the Room database. With SQLiteOpenHelper I always opened it, used it and closed it. But I didn't find any enfor
|
Andre R. |
enforcement to this behaviour with Room
|
Mark M. |
you do not need to close a SQLiteOpenHelper, and frequently we do not close it, because we do not know when it is safe to close
|
Mark M. |
a RoomDatabase works the same way
|
Mark M. |
so, if you are *sure* that you are done with the RoomDatabase and want to close it, you should be able to do so
|
Mark M. |
but, if you do not close it, and your process just terminates normally, that is fine too
|
Mar 20 | 4:20 PM |
Andre R. |
Ok
|
Mark M. |
let me take another question from Milan, and I'll return to you in a little bit
|
Mark M. |
Milan: back to you! do you have another question?
|
Mark M. |
BTW, check out ACTION_MEDIA_BUTTON to see about possibly finding out about volume presses in the background: https://developer.android.com/reference/android...
|
Mark M. |
OK, if either of you have a question, go right ahead
|
Mar 20 | 4:25 PM |
Milan |
In order to listen media broadcast receiver, your app should have audio focus requested. If I got it right
|
Mar 20 | 4:25 PM |
Mark M. |
that may be true nowadays
|
Mark M. |
I have not tried ACTION_MEDIA_BUTTON in quite a long time, before audio focus existed
|
Milan |
btw, regarding my first question... switching on channels is approach for 8+
|
Milan |
what about below 8
|
Mark M. |
you would raise the notification with the same ID but with different settings in the NotificationCompat.Builder
|
Milan |
ah, yes
|
Milan |
ok
|
Milan |
thanks for that one
|
Andre R. |
I am migrating my app to Room. I am still using SQLiteOpenHelper for some activities that I didn't have the time to migrate. Is it safe to use them both ? Because I read an article of Florina Muntenescu where she states that update from your custom SQLiteOpenHelper to SupportSQLiteOpenHelper. Is there any caveats to this approach ?
|
Mark M. |
I would not use SQLiteOpenHelper for the same database as Room
|
Mark M. |
if you have two separate databases, then that should be fine
|
Andre R. |
No same database
|
Mark M. |
then I would either switch to SupportSQLiteOpenHelper or just complete the migration
|
Mark M. |
under the covers, Room uses SupportSQLiteOpenHelper, which by default uses SQLiteOpenHelper
|
Mark M. |
if you also use SQLiteOpenHelper, now you have two helpers for the same database, and that could get you in trouble with synchronization, etc.
|
Mar 20 | 4:30 PM |
Mark M. |
for lighter-weight stuff, a simple callback can work: https://github.com/commonsguy/cw-androidarch/bl...
|
Mar 20 | 4:30 PM |
Andre R. |
Ok. My app rely entirely on the databse
|
Andre R. |
sorry pressed enter before I finished
|
Milan |
View paste
|
Mark M. |
Milan: correct, which is why you would need to rely on broadcasts or AudioManager stuff
|
Milan |
could you be more precise, which stuff?
|
Milan |
except ACTION_MEDIA_BUTTON
|
Mark M. |
since I have almost zero experience with AudioManager, I don't know
|
Mar 20 | 4:35 PM |
Milan |
because I don't want to hijack audio focus
|
Milan |
ok
|
Mark M. |
it's more that it's the primary place that I'd look
|
Mark M. |
and if there is nothing there, then I don't know what else to consider
|
Mark M. |
also, bear in mind that not all devices have hardware volume buttons, so don't do anything that relies upon their existence
|
Milan |
what approach for playing ringtone&vibration would you suggested? via notification or "manually", ringtonemanager for example
|
Mark M. |
if it is tied to a notification, I would use the notification, but not worry about trying to mute things myself
|
Mark M. |
but, I like very simple notification logic
|
Milan |
ok, that was mine approach too, until I hit the wall with mute thing
|
Milan |
thanks Mark, I believe that would be all
|
Milan |
for now :D
|
Mark M. |
OK
|
Andre R. |
My app rely entirely on the database, and one of the main feature is to change this database by restoring other backups, of the same database but with different data. Before I just copied the files from the environment files dir to the database dir and the other way around. But now Room database doesn't allow me to do so. I ended up deleting the database data and copying the data from the database to be restored, for this I am using a direct access to the database through db.openHelper.writableDatabase and attaching the database to be restored with .execSQL("attach database ? as userdb1", arrayOf(path)). It is working, but I would like to know if you have made something like this and have any suggestions.
|
Mark M. |
"But now Room database doesn't allow me to do so" -- why not? it is tied to Room metadata?
|
Mark M. |
I need to explore Room and backup/restore more
|
Mar 20 | 4:40 PM |
Mark M. |
the closest thing that I have done is the encrypt/decrypt support in CWAC-SafeRoom, for encrypting or decrypting an existing database
|
Andre R. |
I remember reading an answe
|
Andre R. |
I remember reading an answer from you in StackOverflow about trying to copy a database file behind Room's back, and the person asking the question were experiencing the same errors than I did.
|
Andre R. |
I am trying to locate the post now.
|
Mark M. |
that would be a scenario where you would want Room to be closed
|
Andre R. |
Yes, but I was unable to do so. Any thoughts ?
|
Mar 20 | 4:45 PM |
Andre R. |
I am using Dagger to instantiate the Room database as a singleton
|
Mark M. |
ideally, you would restore the backup before trying to open Room in the first place
|
Mark M. |
but if RoomDatabase does not support a clean working close(), that's a bug and should get reported (ideally with a reproducible test case)
|
Mark M. |
(BTW, I think I know what Stack Overflow question you are referring to, and *I* can't find it...)
|
Mar 20 | 4:50 PM |
Andre R. |
I will try to make all the steps again when trying to just copy the database file and record the errors to show you. I remember the major problem was to reopen the database when the copy was done.
|
Mark M. |
I have also made a note to play around with this scenario more in the coming weeks
|
Mark M. |
I should have worked on it a while ago
|
Andre R. |
I can send you the code I ended up with if you are interested.
|
Andre R. |
As I said, it is working, but it takes more time than just copying the file
|
Mark M. |
if this is for some open source project, I'd be interested in looking at it
|
Mar 20 | 5:00 PM |
Mark M. |
that is a wrap for today's chat
|
Mark M. |
I will post the transcript to https://commonsware.com/office-hours/ shortly
|
Andre R. |
It is not open source, the app is published. But I don't think there is any industrial secret on it. I don't mind sending it to you and you are free to make any use of it.
|
Mark M. |
the next chat is tomorrow, 9am US Eastern
|
Milan |
have a nice rest of the day
|
Mark M. |
Andre: sorry, but I try to stick with clear licensing, but thanks!
|
Mark M. |
have a pleasant day!
|
Andre R. |
Ok. you too
|
Milan | has left the room |
Andre R. | has left the room |
Mark M. | turned off guest access |