This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get progress bar after selecting a view

 
Suzzane Pinto
Ranch Hand
Posts: 214
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone tell how to implement progressbar in andriod,
iam selecting an image den while uploading i want a progress bar to check if it is loaded successfully
 
santhana samy
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

onClick() of the image put this piece of code...


AsynTask<Void, Void,Void > lTask = new AsynTask<Void, Void,Void >(){

ProgressDialog lDialog;
protected void onPreExecute(){
lDialog = ProgressDialog .show(context, "","Your msg",true);
}

protected void doInBackground(Void... params){
// do your uploading task here
return null;
}

protected void onPostExecute(){
lDialog.dismiss();
}
};
lTask.execute();

 
Suzzane Pinto
Ranch Hand
Posts: 214
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey thanks for the above post,

i have added the following lines in my code but the avd says to force close




and my logcat says:



i dont understd where is it going wrong
 
Tim Moores
Bartender
Pie
Posts: 2488
4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

This seems quite clear, no?

Next time, please post only the operative code - not anything that's commented out- and only a relevant logcat excerpt that shows the output related to your app. Nobody is going to try and look through 1000 lines of something.
 
Suzzane Pinto
Ranch Hand
Posts: 214
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have doubt in this particular lines



i am passing string in doinbackground() and my ftp storefile() returns boolean which is used to store image to server..little confused with that.
please suggest
 
Tim Moores
Bartender
Pie
Posts: 2488
4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does the input parameter of that method have to do with the result of the FTP operation?

You should use the string to pass in the information about what to do, though - it seems that is currently in "var".
 
Suzzane Pinto
Ranch Hand
Posts: 214
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thankyou Tim,

now i have modified the code as


still the image is not getting uploaded...im wondering if running in a different thread really solving the problem of not uploading the whole image to the server.
 
Tim Moores
Bartender
Pie
Posts: 2488
4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't seem to be doing any error checking of the result. The javadocs of the FTPClient class talk about what you should be doing.
 
Suzzane Pinto
Ranch Hand
Posts: 214
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeppieee i hav uploaded the image successfuly,just changed one line in my code
private static final int TEN_KILOBYTES = 1024 * 10*10*10*10;
n its done


thnanks to all those who took interest and replied to me patiently
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic