如何打开三星的设置页面?

huangapple go评论156阅读模式
英文:

How to open Samsung's Settings Page?

问题

以下是您要翻译的内容:

有谁能帮我打开三星手机的设置吗?尝试了以下代码,但不起作用。

代码:

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Intent intent = new Intent();
        intent.setComponent(new ComponentName("com.samsung.android.sm", "com.samsung.android.sm.ui.battery.BatteryActivity"));
        try {
            MainActivity.this.startActivity(intent);
        } catch (ActivityNotFoundException ex) {
            Toast.makeText(MainActivity.this, "此设备未安装智能管理器", Toast.LENGTH_LONG)
                    .show();

        }
    }
}
英文:

Can anyone help me with opening Samsung phone's settings? Tried the following code but it's not working

CODE:

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Intent intent = new Intent();
        intent.setComponent(new ComponentName("com.samsung.android.sm", "com.samsung.android.sm.ui.battery.BatteryActivity"));
        try {
            MainActivity.this.startActivity(intent);
        } catch (ActivityNotFoundException ex) {
            Toast.makeText(MainActivity.this, "Smart manager not installed on this device", Toast.LENGTH_LONG)
                    .show();

        }
    }
}

答案1

得分: 1

你尝试过这个吗?

Intent intent = new Intent(android.provider.Settings.ACTION_SETTINGS);
startActivityForResult(intent, 0);
英文:

Have you tried this?

Intent intent = new Intent(android.provider.Settings.ACTION_SETTINGS);
startActivityForResult(intent, 0);

huangapple
  • 本文由 发表于 2020年4月10日 16:38:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/61136727.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定