Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem with asyncTask that work's on emulator and not on device
    primarykey
    data
    text
    <p>I've a problem with asyncTask. In my app the user must log on. He do it one times, and I saved the login/pwd. When He launch the app for the second times, Instead of display the screen with login and pwd editText, I want to display another xml where there is a progressBar.</p> <p>To do that, I look at if it's a first authentication or not, and corresponding to the answer I put the good xml. When I just display the xml with the progressBar, I do the connection to the server with an asyncTask, and load what I need. </p> <p>That works perfectly on emulator, but when I put the app on m'y Nexus S (Android 2.3.3) that doesn't work, I've just a white screen, and nothing append.</p> <p>The code of my activity : </p> <pre><code>public class AuthentificationActivity extends Activity implements OnClickListener { private Button btnConnection; private EditText edtUserName; private EditText edtPassword; private TextView lblForgottenPass; private ProgressBar progressBar; private TextView txtProgression; private TextView txtAlerts; private EntirePersonBM entirePersonBM = new EntirePersonBM(); private String uidh = new String(); private String userName = new String(); private String password = new String(); private boolean isFirstConnection = true; public static boolean isFinishApp = false; private Selection selection; private SelectionResultSet resultSet; private SharedPreferences settings; private String alerts = null; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); settings = getSharedPreferences("login", 0); isFirstConnection = settings.getBoolean("isFirstConnection", true); try { if (isFirstConnection) { // Put connection screen, and help this.setContentView(R.layout.login); btnConnection = (Button) findViewById(R.id.btnConnection); edtUserName = (EditText) findViewById(R.id.edtUserName); edtPassword = (EditText) findViewById(R.id.edtPassword); lblForgottenPass = (TextView) findViewById(R.id.lblForgottenPass); progressBar = (ProgressBar) findViewById(R.id.progressBar1); txtProgression = (TextView) findViewById(R.id.textView1); txtAlerts = (TextView) findViewById(R.id.txtAlerts); btnConnection.setOnClickListener(this); lblForgottenPass.setOnClickListener(this); } else { // Directly connect to server with saved login/pwd // Retrieve login/pwd this.setContentView(R.layout.splash_login); txtProgression = (TextView) findViewById(R.id.txtProgression); userName = settings.getString("currentUserName", null); password = settings.getString("currentPwd", null); new ConnectionTask().execute(""); } } } catch (Exception e) { Alerts .showAlert(getString(R.string.AlertsErrorOccured), this, true); } } public void connect(SharedPreferences settings) { String login = settings.getString("currentUserName", null); String pwd = settings.getString("currentPwd", null); Log.v("Retrieve user", "Always log &gt;&gt;&gt; Login = " + login); // call server AuthentificationServletCall auth = new AuthentificationServletCall(); try { entirePersonBM = auth.Authentification("BoozterMobile", login, pwd, "passwordHash"); Log.v("call server", "Connecting &gt;&gt;&gt; OK"); } catch (Exception e) { Log.v("call server", "Connecting &gt;&gt;&gt; ERROR :" + e); e.printStackTrace(); } } public void loadMail() { selection = callsUtils.loadingSelection(UserControler.getInstance() .getUidh(), "NEW", null, String .valueOf(BoozterMobileConstants.MAX_VALUES_SUGGESTION), "desc"); if (selection != null) { resultSet = callsUtils.loadingMailList(UserControler.getInstance() .getUidh(), selection, String.valueOf(1)); } if (selection != null &amp;&amp; resultSet != null) { ListHeaderControler.getInstance().setFirstAuthentification(false); ListHeaderControler.getInstance().setRefresh(false); ListHeaderControler.getInstance().setSentMail(false); ListHeaderControler.getInstance().setSplashActivty(true); ListHeaderControler.getInstance().setSel(selection); ListHeaderControler.getInstance().setRs(resultSet); ListHeaderControler.getInstance().setMailHeaderList( resultSet.getEuis()); } } private class ConnectionTask extends AsyncTask&lt;String, Void, Object&gt; { protected Void doInBackground(String... args) { Log.v("AsyncTask", "Start connectionTask"); connect(settings); return null; } protected void onPostExecute(Object result) { // Pass the result data back to the main activity txtProgression.setText(getString(R.string.lblGetBlock)); new BlockLoaderTask().execute(""); } } private class BlockLoaderTask extends AsyncTask&lt;String, Void, Object&gt; { protected Void doInBackground(String... args) { Log.v("AsyncTask", "Start BlockLoaderTask"); BlockControler.getInstance().setListWhere( BlocksUtils.generateList(String .valueOf(BoozterMailConstants.BLOCK_CATEGORY_ID), true, null)); return null; } protected void onPostExecute(Object result) { // Pass the result data back to the main activity txtProgression.setText(getString(R.string.lblGetMails)); new MailLoaderTask().execute(""); } } private class MailLoaderTask extends AsyncTask&lt;String, Void, Object&gt; { protected Void doInBackground(String... args) { Log.v("AsyncTask", "Start BlockLoaderTask"); loadMail(); return null; } protected void onPostExecute(Object result) { // create Intent Intent defineIntent = new Intent(AuthentificationActivity.this, HeaderMailDisplayActivity.class); // Object that allows to pass the mail's seqnums and person's uidh // onto headerMail activity Bundle objetbunble = new Bundle(); objetbunble.putString("positionList", String.valueOf(1)); defineIntent.putExtras(objetbunble); // call headerMail activity AuthentificationActivity.this.startActivity(defineIntent); } } } </code></pre> <p>Please help me, I try many method, nothing works, and I given up hope of doing what I want</p> <p><strong>I just found a device with android 2.1, and it works fine. So there is something that is not compatible with android 2.3 ?</strong></p>
    singulars
    1. This table or related slice is empty.
    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