Aller au contenu
View in the app

A better way to browse. Learn more.

Forum de Frandroid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Résolu] onConfigurationChanged et onCreate sous ICS

Featured Replies

Posté(e)

Bonjour,

J'ai cherché toute la soirée une réponse à cette question : pourquoi mon activité est recréée alors que je semble avoir convenablement rédigé mon code pour que celui-ci passe dans la fonction onConfigurationchanged et non onCreate lors du passage de l'activity de portrait à paysage (et vise versa) ?

Grosso modo :

Code :

public class AddUsersActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.addusers);
getActionBar().setDisplayHomeAsUpEnabled(true);

mRing = new Ring(new ArrayList<People>());
setRingPrefs();

mList = (ListView) findViewById(R.id.addusers_list);
mList.setAdapter( new AddUsersAdapter(this) );

Log.i("Activity", "onCreate() was called.");
}

@Override
public void onConfigurationchanged(Configuration newConfig) {
super.onConfigurationchanged(newConfig);
Log.i("Activity", "onConfigurationchanged was called.");
}
}

Manifest :


<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="15" />
…
<activity
android:name=".activity.AddUsersActivity"
android:configChanges="orientation|keyboardHidden"
android:label="@string/title_activity_home">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="HomeActivity" />
</activity>

Log :

08-22 23:42:27.561: I/System.out(9028): Creation de l'engrenage

08-22 23:42:27.577: I/Activity(9028): onCreate() was called.
08-22 23:42:27.577: I/Activity(9028): onresume() was called.
*Roration*
08-22 23:42:29.967: I/Activity(9028): onpause() was called.
08-22 23:42:29.975: I/Activity(9028): onSaveInstanceState() was called.
08-22 23:42:29.975: I/Activity(9028): onstop() was called.
08-22 23:42:30.045: I/Activity(9028): onCreate() was called.
08-22 23:42:30.053: I/Activity(9028): onresume() was called.

Une idée ? Merci bien!

Solution :

En ajoutant "screenSize|smallestScreenSize" dans le manifest, cela fonctionne. Personnellement j'ai mis

android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"

Cela semble être un pré-requis depuis le SDK ICS.

Modifié par Bap`NesS

Posté(e)
  • Auteur

Toujours pareil. :D

EDIT :

Solution trouvée : direction le premier post.

Modifié par Bap`NesS

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.

Account

Navigation

Rechercher

Rechercher

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.