Closed. This question needs debugging details。它当前不接受答案。
                        
                    
                
            
        
            
        
                
                    
                
            
                
                    想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                
                    18天前关闭。
            
        

    

谁能帮我打开三星手机的设置?尝试了以下代码,但无法正常工作

码:

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

        }
    }
}

最佳答案

你有尝试过吗?

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

07-28 09:28