英文:
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);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论