Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Not sure whether i am right about what you want,but in my case it works good.Try if it can help you.<br> I used here <strong>2 buttons</strong> to set profile as <strong>silent</strong> and <strong>default</strong> mode.Trigger your events when those will activate upon button click.</p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final TextView text = (TextView) findViewById(R.id.text1); Button silent = (Button) findViewById(R.id.silent); Button default = (Button) findViewById(R.id.default); final AudioManager mode = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE); silent.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { text.setText("The Mobile in Silent Mode"); //i use example case,trigger your event here mode.setRingerMode(AudioManager.RINGER_MODE_SILENT); Toast.makeText(getBaseContext(), "Silent Mode Activated",Toast.LENGTH_LONG).show() } }); default.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { text.setText("The Mobile in Default Mode"); //trigger your event here mode.setRingerMode(AudioManager.RINGER_MODE_NORMAL); Toast.makeText(getBaseContext(), "Default Mode Activated", Toast.LENGTH_LONG).show(); } }); } </code></pre> <p>Apparently this can also help you..</p> <ul> <li><a href="https://stackoverflow.com/questions/2048427/how-can-i-detect-whether-the-android-phone-in-silent-mode-programatically">how can I detect whether the android phone in Silent mode programmatically</a></li> <li><a href="https://stackoverflow.com/questions/10360815/how-to-make-android-phone-silent-in-java?rq=1">How to make android phone silent in java</a></li> <li><a href="https://stackoverflow.com/questions/6691727/how-to-find-whether-phone-is-in-sleep-idle-mode-for-android?rq=1">How to find whether phone is in sleep/idle mode for Android</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload