• 铃声设置


     1 // 显示和设置铃声
     2     @Override
     3     protected void onCreate(Bundle savedInstanceState) {
     4         super.onCreate(savedInstanceState);
     5         setContentView(R.layout.fragment_main);
     6 
     7     }
     8 
     9     public void onclick(View view) {
    10         switch (view.getId()) {
    11         // 来电铃声
    12         case R.id.button1:
    13             Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
    14             intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE,
    15                     RingtoneManager.TYPE_RINGTONE);
    16             intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "设置来电铃声");
    17             startActivityForResult(intent, 1);
    18             break;
    19         // 闹钟铃声
    20         case R.id.button2:
    21             Intent intent2 = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
    22             intent2.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE,
    23                     RingtoneManager.TYPE_ALARM);
    24             intent2.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "设置闹钟铃声");
    25             startActivityForResult(intent2, 2);
    26             break;
    27         // 闹钟铃声
    28         case R.id.button3:
    29             Intent intent3 = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
    30             intent3.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE,
    31                     RingtoneManager.TYPE_NOTIFICATION);
    32             intent3.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "设置通知铃声");
    33             startActivityForResult(intent3, 3);
    34             break;
    35         }
    36     }
    37 
    38     @Override
    39     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    40         // TODO Auto-generated method stub
    41         super.onActivityResult(requestCode, resultCode, data);
    42         if (resultCode != RESULT_OK) {
    43             return;
    44         } else {
    45             Uri uri = data
    46                     .getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
    47             if (uri != null) {
    48                 switch (requestCode) {
    49                 // 来电铃声
    50                 case 1:
    51                     RingtoneManager.setActualDefaultRingtoneUri(this,
    52                             RingtoneManager.TYPE_RINGTONE, uri);
    53 
    54                     break;
    55                 // 闹钟铃声
    56                 case 2:
    57                     RingtoneManager.setActualDefaultRingtoneUri(this,
    58                             RingtoneManager.TYPE_ALARM, uri);
    59                     break;
    60                 // 闹钟铃声
    61                 case 3:
    62                     RingtoneManager.setActualDefaultRingtoneUri(this,
    63                             RingtoneManager.TYPE_NOTIFICATION, uri);
    64                     break;
    65                 }
    66             }
    67         }
    68     }
    69 
    70 }

  • 相关阅读:
    Android BlueDroid(一):BlueDroid概述 【转】
    halcon学习笔记——机器视觉工程应用的开发思路【转】
    git log用法【转】
    git 使用详解(5)-- get log 查看提交历史【转】
    10 个迅速提升你 Git 水平的提示【转】
    触摸屏学习笔记---自容与互容【原创】
    Linux按键驱动程序设计详解---从简单到不简单【转】
    LCD参数解释及计算【转】
    5.24 Declaring Attributes of Functions【转】
    【SVN Working copy is too old (format 10, created by Subversion 1.6)】解决方式
  • 原文地址:https://www.cnblogs.com/my334420/p/6925015.html
Copyright © 2020-2023  润新知