How to clear Intent that started Activity?

后端 未结 9 1160
攒了一身酷
攒了一身酷 2021-02-03 21:07

At the beginning Activity is launched by an Intent and something is done with this Intent.

When I change orientation of my Activity, it\'s reloaded again and Intent is

9条回答
  •  伪装坚强ぢ
    2021-02-03 21:42

    I had similar problem. This helped me. Maybe you have to also use onSaveInstanceState(Bundle outState) and add extra data to the bundle so inState is not null, not sure.

    Intent activityIntent = null; // Subsequent times it's null
    
    @Override 
    protected void onCreate(Bundle inState) {
        super.onCreate(inState);
        .
        .
        if (inState!=null) {
            /*Recreating activity with a saved state*/
        } else {
            /*Creating activity*/
            activityIntent = getIntent(); // First time through intent is used
            /*Get your Extra Intent data here. You will be capturing data on 1st creation. */
    }
    

提交回复
热议问题