Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Stackmob: Prompting logged in user information
    primarykey
    data
    text
    <p>I began to use stackmob for Android development. And I went into an issue. Indeed after creating the interface for the user to log in, I wanted my home page to prompt the actual logged-in user's name on the top of it.</p> <p>So I used the getloggedInUser (Class&lt;T>, stackMobCallBack&lt;T>) for getting my user. The first issue was that I was not able to get this user outside of the call back. So I created a method that I call from the getloggedin user method's callBack. There I went into another issue; the action from the method had no impact on my view. Indeed when the homepage prompts, the text remain the same (without adapting itself to the logged in user). What is strange is that if I reduce my application and then resume it, the text is updated. Here is my code:</p> <pre><code>public class MainActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); StackMobAndroid.init(getApplicationContext(), 0, "XXXXX.XXXXXX.XXXXX"); TextView welcomeText = (TextView) findViewById(R.id.welcomeHead); User.getLoggedInUser(User.class,new StackMobQueryCallback&lt;User&gt;(){ public void failure(StackMobException e) { // TODO Auto-generated method stub } public void success(List&lt;User&gt; list) { User loggedUserf = list.get(0); setMyAppUser(loggedUserf); finish(); } }); public void setMyAppUser(User user){ String welcome = welcomeText.getText().toString(); welcome = welcome+" "+user.getUsername(); welcomeText.setText(welcome); } } </code></pre> <p>I have been stuck on it for a long time, and I guess that the issue is related to the fact that a callback is an asynchronous method, but I used every kind of stuff like invalidate or postinvalidate methods on my view for fixing it ... nothing worked.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload