Hi! im trying to show a progressdialog while there's a resquest to a server. Im using a service with a thread for a rest type request, the is the tab activity oncreate method:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tabpanel);
showDialog(PROGRESS_DIALOG_ID);
String session=getIntent().getStringExtra(IpdmsLauncher.ID_SESSION);
sessionId= new Session();
sessionId.setSession(session);
prefs=PreferenceManager.getDefaultSharedPreferences(this);
//get element list view processes ListView list=(ListView)findViewById(R.id.processlist);
//TABS// // Resources res = getResources(); // Resource object to get Drawables TabHost tabHost = getTabHost(); // The activity TabHost TabHost.TabSpec spec; // Reusable TabSpec for each tab
// Initialize a TabSpec for each tab and add it to the TabHost
//----TAB1 - PROCESSLIST----//
spec = tabHost.newTabSpec("processlist").setIndicator("Process List", getResources().getDrawable(R.drawable.iconpesquisa))
.setContent(R.id.processlist);
tabHost.addTab(spec);
//content elements bindService(new Intent(this, ServiceCall.class), svcConnect,BIND_AUTO_CREATE);
//adapter for listview adapter=new ProcessAdapter(); ((ListView)findViewById(R.id.processlist)).setAdapter(adapter);
list.setOnItemClickListener(new OnItemClickListener(){
@Override public void onItemClick(AdapterView adaptview, View view, int position, long id) {
TextView proc=(TextView)view.findViewById(R.id.processnr);
searchProcess(proc.getText().toString());
}});
And this is the service onCreate method:
@Override public void onCreate() {
super.onCreate(); //launch new thread new Thread(threadBody).start(); }
//create runnable with job to do
private Runnable threadBody=new Runnable() {
public void run() { Looper.prepare(); while (active.get()) { for (Account l : accounts.values()) { restRequest(l); } SystemClock.sleep(POLL_PERIOD); } Looper.loop(); } };
I want to show the progressdialog while we wait for the response. But im getting thread errors id i create the dialog in the service.