Office Hours — Today, March 20

Saturday, March 17

Mark M.
has entered the room
Mark M.
turned on guest access
Mar 20
4:00 PM
Milan
has entered the room
4:05 PM
Mark M.
hello, Milan!
how can I help you today?
Milan
hello Mark
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
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
mAudioManager.adjustSuggestedStreamVolume(mAudioManager.ADJUST_MUTE, AudioManager.STREAM_NOTIFICATION, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
something like this
this only mutes sound, vibration is still there
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
rught
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
dialer
4:10 PM
Mark M.
I do not know what the behavior is that you are seeking
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
I see that Mark is calling me, I don't want to answer
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
yep, but native does the same thing
native dialer
you receive incoming call
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
there may be other solutions, but i do not know them
Milan
ok, I am good with that solution, will try it
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
4:15 PM
Mark M.
if your app is in the foreground, I think they result in KeyEvents
Milan
bkg
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
Andre: hi! do you have a question?
Milan
not sure, Romain Guy says it is not possible
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
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
a RoomDatabase works the same way
so, if you are *sure* that you are done with the RoomDatabase and want to close it, you should be able to do so
but, if you do not close it, and your process just terminates normally, that is fine too
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
Milan: back to you! do you have another question?
BTW, check out ACTION_MEDIA_BUTTON to see about possibly finding out about volume presses in the background: https://developer.android.com/reference/android...
OK, if either of you have a question, go right ahead
4:25 PM
Milan
In order to listen media broadcast receiver, your app should have audio focus requested. If I got it right
4:25 PM
Mark M.
that may be true nowadays
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+
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
ok
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
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
under the covers, Room uses SupportSQLiteOpenHelper, which by default uses SQLiteOpenHelper
if you also use SQLiteOpenHelper, now you have two helpers for the same database, and that could get you in trouble with synchronization, etc.
4:30 PM
Mark M.
for lighter-weight stuff, a simple callback can work: https://github.com/commonsguy/cw-androidarch/bl...
4:30 PM
Andre R.
Ok. My app rely entirely on the databse
sorry pressed enter before I finished
Milan
View paste
when you finish with Andre... I run on your answer: https://stackoverflow.com/questions/8972647/how-to-receive-volume-changed-events-for-the-voice-in-call-stream-type/8974510
it seems that there is no option to listen onKeyDown from service or application class
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?
except ACTION_MEDIA_BUTTON
Mark M.
since I have almost zero experience with AudioManager, I don't know
4:35 PM
Milan
because I don't want to hijack audio focus
ok
Mark M.
it's more that it's the primary place that I'd look
and if there is nothing there, then I don't know what else to consider
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
but, I like very simple notification logic
Milan
ok, that was mine approach too, until I hit the wall with mute thing
thanks Mark, I believe that would be all
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?
I need to explore Room and backup/restore more
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
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.
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 ?
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
but if RoomDatabase does not support a clean working close(), that's a bug and should get reported (ideally with a reproducible test case)
(BTW, I think I know what Stack Overflow question you are referring to, and *I* can't find it...)
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
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.
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
5:00 PM
Mark M.
that is a wrap for today's chat
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!
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

Saturday, March 17

 

Office Hours

People in this transcript

  • Andre Rocha
  • Mark Murphy
  • Milan