Sie benötigen onSaveInstanceState (Bundle savedInstanceState) und schreiben Sie die Anwendungszustandswerte, die Sie mit dem Bundle Parameter wie folgt ändern möchten außer Kraft zu setzen:
Sie Instanz von jeder Variablen wie diese
gespeichert wurden, können
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
super.onSaveInstanceState(savedInstanceState);
// Save UI state changes to the savedInstanceState.
// This bundle will be passed to onCreate if the process is
// killed and restarted.
savedInstanceState.putBoolean("myBoolean", false);
savedInstanceState.putDouble("myDouble", 1.121);
savedInstanceState.putInt("myInt", 0);
savedInstanceState.putString("myString", "Your String");
// etc.
}
und das ändert können Sie so retrive
@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
// Restore UI state from the savedInstanceState.
// This bundle has also been passed to onCreate.
boolean myBoolean = savedInstanceState.getBoolean("myBoolean");
double myDouble = savedInstanceState.getDouble("myDouble");
int myInt = savedInstanceState.getInt("myInt");
String myString = savedInstanceState.getString("myString");
}
Hoffe, das wird Ihnen helfen .cheers!
UPDATE:
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
{
p.set("orientation", "portrait");
p.set("rotation",90);
}
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
{
p.set("orientation", "landscape");
p.set("rotation", 90);
}
und setzen Eigenschaft wie folgt:
Camera.Parameters parameters = camera.getParameters();
parameters.set("orientation", "portrait");
camera.setParameters(parameters);
Lesen Sie [this] (https://developer.android.com/guide/topics/resources/runtime-changes.html) zur Handhabung von Orientierungsänderungen in Android. – NonCreature0714