Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2214731
  • 博文数量: 436
  • 博客积分: 9833
  • 博客等级: 中将
  • 技术积分: 5558
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-29 10:27
文章存档

2013年(47)

2012年(79)

2011年(192)

2010年(118)

分类:

2010-11-11 19:35:16

组长 刘宇 组员 马思雨 刘晓楠 吕超 赵朝

本周我们组已将google android应用开发项目全部完成,以下是最后一部分代码

package com.zz.android.RingProfile;

import com.yarin.android.RingProfile.R;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
import android.util.Log;

public class RingBroadcastReceiver extends BroadcastReceiver
{
 private static final String TAG  = "RingBroadcastReceiver";
 public static final String VIBRATE_CHANGED = "com.yarin.android.RingProfile.VIBRATE_CHANGED";
 public static final String SILENT_CHANGED = "com.yarin.android.RingProfile.SILENT_CHANGED";
 public static final String RV_CHANGED  = "com.yarin.android.RingProfile.RV_CHANGED";
 public static final String RING_CHANGED = "com.yarin.android.RingProfile.RING_CHANGED";
 public static final int REQUEST_CODE = 0;
 @Override
 public void onReceive(Context context, Intent intent)
 {
  AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
  int checkedId = intent.getIntExtra("checkedId", 0);
  Log.e(TAG, checkedId + intent.getAction());
  // 切换情景模式(赵朝)
  switch (checkedId)
  {
   case R.id.ring_and_vibrate01:
   case R.id.ring_and_vibrate02:
    ringAndVibrate(audio);
    break;
   case R.id.vibrate01:
   case R.id.vibrate02:
    vibrate(audio);
    break;
   case R.id.silent01:
   case R.id.silent02:
    silent(audio);
    break;
   default:
    ring(audio);
    break;
  }
 }
 // 铃声和震动(刘晓楠)
 protected void ringAndVibrate(AudioManager audio)
 {
  audio.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
  audio.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_ON);
  audio.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION, AudioManager.VIBRATE_SETTING_ON);
 }
 // 铃声(吕超)
 protected void ring(AudioManager audio)
 {
  audio.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
  audio.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_OFF);
  audio.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION, AudioManager.VIBRATE_SETTING_OFF);
 }
 // 震动(刘宇)
 protected void vibrate(AudioManager audio)
 {
  audio.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
  audio.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_ON);
  audio.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION, AudioManager.VIBRATE_SETTING_ON); 
 }
 // 静音(马思雨)
 protected void silent(AudioManager audio)
 {
  audio.setRingerMode(AudioManager.RINGER_MODE_SILENT);
  audio.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_OFF);
  audio.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION, AudioManager.VIBRATE_SETTING_OFF);
 }
}

 
阅读(1225) | 评论(0) | 转发(0) |
0

上一篇:邓金龙(5)

下一篇:第六次总结

给主人留下些什么吧!~~