Skip to content Skip to sidebar Skip to footer

How To Access This Variable From An Android Oncreate Method?

The problem is that I can't access the userId variable value from inside the onCreate method. I'm accessing the activity from two different activities so I have to check from which

Solution 1:

Sorry, changed my previous answer. Tried it and it worked for me.

Here it is

publicstaticclassDetailsextendsActivity {

   staticlong userId;

    longgetDetailsUserId(){
        return userId; //This is the variable value I can't get.
    }

    @OverridepublicvoidonCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.grid_layout);
        getActionBar().setDisplayHomeAsUpEnabled(true);

        final String caller;

        //Get previous activity name
        caller = getIntent().getStringExtra("com.mysite.myapp.Caller");

        //Get user id from "List"if(caller.equals("List")){
            ListuserListId=newList();
            userId = userListId.getUserListId();
        }

        //Get user id from "Profile Saved"elseif(caller.equals("ProfileSaved")){
            ProfileSavedsavedUserId=newProfileSaved();
            this.userId = savedUserId.getSavedUserId();
        }

}

}

Post a Comment for "How To Access This Variable From An Android Oncreate Method?"