Android系统。呼叫系统对话框

时间:2013-04-26 12:41:43

标签: java android

有没有办法从我的应用程序中以编程方式打开系统对话框settings->location & security->Install from SD card

1 个答案:

答案 0 :(得分:0)

您至少通过以下代码启动安全设置。

public class MainActivity extends Activity {

Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    button = (Button) findViewById(R.id.button1);

    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            final Intent intent = new Intent(Intent.ACTION_MAIN, null);
            intent.addCategory(Intent.CATEGORY_LAUNCHER);
            final ComponentName cn = new ComponentName(
                    "com.android.settings",
                    "com.android.settings.SecuritySettings");
            intent.setComponent(cn);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
        }
    });
}