2011-11-01 73 views
7

以某种方式以编程方式切换内置在Android个人档案中是可能的吗?以编程方式切换Android个人档案

我打算写另一个配置文件应用程序,但实际上内置配置文件对我的需求绰绰有余,我只需要自动切换它们。

+0

嗨@Laimoncijus。你有没有找到任何解决方案,以编程方式切换android配置文件 –

+0

@Arun库马尔Munusamy:不幸的不是。但是当时我只是在短时间看着。也许与此同时,已经有这样的东西...让我知道,如果你找到一些东西,谢谢! – Laimoncijus

+0

感谢您的回复......我已经整理出一般,无声和振动模式之间的切换。 –

回答

4
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(); 

    } 

    } 
    }); 
    } 
    } 

来源link

+2

尽管这个链接可能回答这个问题,但最好在这里包含答案的重要部分,并提供供参考的链接。如果链接页面更改,则仅链接答案可能会失效。 – animuson