public class ProfileChangerActivity extends Activity {
/** Called when the activity is first created. */
ToggleButton tbt;
TextView txtview;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tbt = (ToggleButton) findViewById(R.id.togglebutton);
txtview = (TextView) findViewById(R.id.textview);
txtview.setText("Welcome to Profile Changer Application");
final AudioManager mobilemode = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
tbt.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
if(tbt.getText().toString().equals("Switch to LOUD"))
{
mobilemode.setRingerMode(AudioManager.RINGER_MODE_SILENT);
txtview.setText("SILENT profile activated !");
Toast.makeText(getBaseContext(),"SILENT profile activated ",Toast.LENGTH_LONG).show();
}
else if(tbt.getText().toString().equals("Switch to SILENT"))
{
mobilemode.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
txtview.setText("LOUD profile activated !");
Toast.makeText(getBaseContext(),"LOUD profile activated !",Toast.LENGTH_LONG).show();
}
}
});
}
}
Sorgente link.
fonte
2012-05-18 12:55:16
Ciao @Laimoncijus. Hai trovato qualche soluzione per cambiare i profili Android a livello di programmazione –
@Arun Kumar Munusamy: sfortunatamente no. Ma stavo guardando solo allora per poco tempo. Forse nel frattempo c'è già qualcosa per questo ... Fammi sapere se trovi qualcosa, grazie! – Laimoncijus
Grazie per la tua risposta ... ho deciso di passare tra le modalità generali, silenziose e vibranti .. –