V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
gaoshiba
V2EX  ›  程序员

分享 ADB 设置 Android 铃声,通知声教程,适用于无法通过设置自定义铃声的情况,例如我使用的某为儿童手表。

  •  1
     
  •   gaoshiba · Feb 8, 2021 · 2484 views
    This topic created in 1916 days ago, the information mentioned may be changed or developed.

    系统自带铃声太少,避免和别人撞音,花了一上午终于搞定。

    直接上 code!!!

    # 电话铃声简单,直接指定文件路径
    
    adb push 铃声.ogg /sdcard/path/xx.ogg
    
    adb shell settings put system ringtone /sdcard/path/xx.ogg
    
    
    # 通知声,对我这种小白比较难,不能再像电话铃声一样直接指定路径
    
    adb push 通知声.ogg /sdcard/path/xx.ogg
    
    # 需要事先将此通知声保存到数据库,懒得深入研究,就直接找了个数据库已经存在的行,直接 update 更新为我自定义的文件路径完成的,和 sql 更新语句逻辑上差不多,请百度。
    
    # 查询数据库看有没有音乐文件
    
    adb shell content query --uri content://media/external/audio/media/
    
    # 如果有的话,按照下图去针对相应的 key 更新 value 就行了。
    
    # 当然 dalao 直接 insert 也没问题
    
    # 更新数据
    
     adb shell content update --uri content://media/external/audio/media/  --bind 键:s:"值" --where "_id='文件 ID'"
    
    
    # 最后
    
    adb shell settings put system notification_sound content://media/external/audio/media/71
    
    

    laji

    Supplement 1  ·  Feb 8, 2021

    完整版

    // 添加通知声
    
    adb shell content insert --uri content://media/internal/audio/media/ --bind _data:s:"/sdcard/Musics/sound_picker_track_109.ogg" --bind is_notification:s:"1" --bind title:s:"铃声选项中会看到的文件名字"
    
    //电话铃声
    
    adb shell content insert --uri content://media/internal/audio/media/ --bind _data:s:"/sdcard/Musics/sound_picker_track_109.ogg" --bind is_ringtone:s:"1" --bind title:s:"铃声选项中会看到的文件名字"
    
    
    Supplement 2  ·  Feb 9, 2021

    laji

    3 replies    2021-02-08 22:55:30 +08:00
    gaoshiba
        1
    gaoshiba  
    OP
       Feb 8, 2021
    又看了一下,存入了数据库的话,铃声选择时可以看到,电话铃声如果直接指定路径,铃声虽然已经设置,但是铃声选项中不会存在。
    gaoshiba
        2
    gaoshiba  
    OP
       Feb 8, 2021
    //新增

    adb shell content insert --uri content://media/internal/audio/media/ --bind _data:s:"文件路径"

    //插入完成更新相应的 value
    电话铃声:is_ringtone=1,通知音:is_notification=1
    smilenceX
        3
    smilenceX  
       Feb 8, 2021
    非常感谢。收藏一下,万一用到了呢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3536 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 10:37 · PVG 18:37 · LAX 03:37 · JFK 06:37
    ♥ Do have faith in what you're doing.