Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get progress dialog until get the response from service in android?
    primarykey
    data
    text
    <p>I am using service for running long background tasks in my application, in the service these functions are running login to XMPP and getting some data from XMPP server. i want to show the progress bar upto login completed. How to get response from service to activity to Update progress bar properly to avoid some exceptions in UI. I am calling service like this</p> <pre><code>final Intent gtalk_intent = new Intent(AccountsActivity.this, GtalkService.class); gtalk_intent.putExtra("user_name", acc.getAcc_Name()); gtalk_intent.putExtra("user_pass", acc.getAcc_Pass()); startService(gtalk_intent); </code></pre> <p>this is the code from service</p> <pre><code>public class PmService extends Service { @Override public IBinder onBind(Intent intent) { return mBinder; } public class PmBinder extends Binder { public PmService getService() { return PmService.this; } } @Override public void onCreate() { super.onCreate(); context = this; app_preferences = new AppPreferences(this); chat_source = new ChatsDataSource(this); chat_source.open(); } @Override public int onStartCommand(Intent intent, int flags, int startId) { Bundle extras = intent.getExtras(); if(extras == null) { full_name = extras.getString("user_name"); if(full_name.contains("@")) { String[] _na = full_name.split("@"); U_name = _na[0]; } U_pass = extras.getString("user_pass"); } new PmAsync().execute(); return START_STICKY; } private class PmAsync extends AsyncTask&lt;Void, Void, Void&gt; { @Override protected void onPreExecute() { super.onPreExecute(); } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); } @Override protected Void doInBackground(Void... params) { SASLAuthentication.supportSASLMechanism("PLAIN", 0); ConnectionConfiguration config = new ConnectionConfiguration(server_host, SERVER_PORT, SERVICE_NAME); configure(ProviderManager.getInstance()); m_connection = new XMPPConnection(config); try { m_connection.connect(); Roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.manual); } catch (XMPPException e) { e.printStackTrace(); } try { m_connection.login(U_name, U_pass); setPacketFilters(); } catch (XMPPException e) { } return null; } } </code></pre> <p>i want to show the progress bar upto login completed, how to response from service after login completed?</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.
 

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