android - Lost variable value inside ASyncTask -


I am trying to retrieve the GCM registration ID. For this, I am using ASCNETK, however, the variable is getting the registration ID (I'm logging it, and I can see it on the logcote), but when I have to put this variable in another function, then This is showing an empty value.

Here is the code:

  Private Zero Registrar (REGId) {regId = GCMRegistrar.getRegistrationId (getApplicationContext ()); New AsyncTask & lt; Zero, zero, zero> () {@Override Secure Voice Downline Background (Zero ... Parameter) {if (regId.equals ("")) {GoogleCloudMessaging GCM = GoogleCloudMessaging. GetInstance (getApplicationContext ()); Try RegId = gcm.register (SENDER_ID); Log D. ("RGID", regId); } Grip (IOException E) {// TODO Auto-Generated Catch Block e.printStackTrace (); }} Return tap; }}. Execute (tap, tap, null); }   

It seems that your registrar calls the REGId () function to regId Assigning a value for (which I think is global) and then the function is trying to use this variable immediately after the call (?). If this is the case, then the problem can be that you can do this by Asynccatc To complete the created background thread, the variables are reaching before running. Using the onPostExecute () method, make sure that you are not reaching any variable set in doInBackground , unless you can ensure that the background thread is completed is. Hope it helps.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -