如何使用CheckBox启用/禁用Android中的振动和音调

时间:2016-02-18 05:10:14

标签: android notifications vibrate

我正在设置Activity,我需要启用或禁用振动/音调。我需要学习如何在我的应用程序中执行这两个功能。我还提供了设置活动的快照。我已尝试使用此代码进行振动,但我不知道如何在复选框中使用此代码。

<div ng-app="myApp" ng-controller="MyController">
<h4>
  Two Way Data Bind
</h4>
<lable style="color:green"> The value you picked (JSON): </lable>
{{value.val}}

</br>
<div close-others="oneAtATime">
  <uib-accordion-group ng-repeat="num in list">
      <uib-accordion-heading>
          {{ num.Title }}                                 
      </uib-accordion-heading>
        <div class="list-group"> 
          <a href="#" ng-repeat="oum in num.Projectors" ng-model="num" ng-click="value.val=num">
            <li> {{ oum.Projector }} </li>
          </a>
        </div>
  </uib-accordion-group>

  <h4>
  Listing all Models for picket Projector {{num}}: </h4>

  <uib-accordion-group ng-repeat="first in value">
    <uib-accordion-group ng-repeat="second in first.Projectors">
           {{second.Model}}
    </uib-accordion-group>
  </uib-accordion-group>

 </div>
</div>

1 个答案:

答案 0 :(得分:0)

首先,您必须在 SharedPreference 中存储复选框值 请参阅此链接 Here

然后使用条件检查此商店值并执行振动和振铃代码。

  AudioManager audioManager = (AudioManager) this.getApplicationContext()
            .getSystemService(Context.AUDIO_SERVICE);

   audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);