Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8414385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:09:20+00:00 2026-06-10T01:09:20+00:00

*I have class which load some files and update the UI…It takes some times

  • 0

*I have class which load some files and update the UI…It takes some times to view the result,… So I want to add a loading bar or progress bar. Some data has been passed by other activity(Bundle extras1 = getIntent().getExtras();). But I am downloading one image per item… I think that takes more time. Any one can help me?

This is my code:

public class ShowSelectedEvents extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.viewdetailsevents);
    Bundle extras1 = getIntent().getExtras();
    String eventTitle = extras1.getString("eventTitle");
    final String address = extras1.getString("address");
    String date = extras1.getString("date");
    String time = extras1.getString("time");
    final String fix = extras1.getString("fix");
    final String mobile = extras1.getString("mobile");
    final String web = extras1.getString("web");
    final String mail = extras1.getString("mail");
    String imageLink = extras1.getString("imageLink");
    final String videoLink = extras1.getString("videoLink");
    // Add item image
    Bitmap bitMap = null;
    try {
        bitMap = DownloadImage("imageLink);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    ImageView imageItem = (ImageView) findViewById(R.id.imageItem);
    imageItem.setImageBitmap(bitMap);
    TextView viewTitle = (TextView) findViewById(R.id.viewTitle);
    viewTitle.setText(eventTitle);
    TextView viewDateTime = (TextView) findViewById(R.id.dateTime);
    viewDateTime.setText("Event is on "+date +" @ "+ time);
    // View Address
    TextView viewAdd = (TextView) findViewById(R.id.viewAddress);   
    viewAdd.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC),Typeface.ITALIC);
    viewAdd.setText(address);
    // On click open Navigation
    if (!(address.equals("-"))){
        ImageView navigationIcon = (ImageView) findViewById(R.id.imageMapNavigation);
        navigationIcon.setOnClickListener(new OnClickListener() {           
            @Override
            public void onClick(View v) {
                String url = "google.navigation:q="+address;
                Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));            
                startActivity(i);
            }
        }); 
    }else{
        Context context = getApplicationContext();
        CharSequence text = "Address is incomplete!";
        int duration = Toast.LENGTH_SHORT;
        Toast toast = Toast.makeText(context, text, duration);
        toast.show();
    }
    // View Phone number
    TextView viewPhoneNumber = (TextView) findViewById(R.id.viewPhoneNumber);
    viewPhoneNumber.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC),Typeface.ITALIC);
    viewPhoneNumber.setText(fix);
    // On click open call 
    if (!(fix.equals("-"))){
        viewPhoneNumber.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                String url = "tel:"+fix;
                Intent i = new Intent(Intent.ACTION_CALL, Uri.parse(url));  
                startActivity(i);
            }
        });
    }
    //View Mobile number
    TextView viewMobileNumber = (TextView) findViewById(R.id.viewMobileNumber);
    viewMobileNumber.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC),Typeface.ITALIC);
    viewMobileNumber.setText(mobile);
    // on click call mobile number
    if (!(mobile.equals("-"))){
        viewMobileNumber.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                String url = "tel:"+mobile;
                Intent i = new Intent(Intent.ACTION_CALL, Uri.parse(url));  
                startActivity(i);
            }
        });
    }
    //View web url
    TextView viewWeb = (TextView) findViewById(R.id.viewWeb);
    viewWeb.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC),Typeface.ITALIC);
    viewWeb.setText(web);
    //on click open web browser
    if (!(web.equals("-"))){
        viewWeb.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(web));
                startActivity(i);
            }
        });
    }
    TextView viewMail = (TextView) findViewById(R.id.viewMailAddress);
    viewMail.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC),Typeface.ITALIC);
    viewMail.setText(mail);
    if(!(mail.equals("-"))){
        viewMail.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
                emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {mail});
                emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Contact from tamilpage.ch");
                emailIntent.setType("text/plain");
                startActivity(Intent.createChooser(emailIntent, "Send a mail ..."));
            }
        });
    }
    // On click play the video
    if (!(address.equals("-"))){
        ImageView videoIcon = (ImageView) findViewById(R.id.videoButton);
        videoIcon.setOnClickListener(new OnClickListener() {            
            @Override
            public void onClick(View v) {
                Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                        Uri.parse(videoLink));
                startActivity(browserIntent);
            }
        }); 
    }else{
        Context context = getApplicationContext();
        CharSequence text = "No advert video for this event";
        int duration = Toast.LENGTH_SHORT;
        Toast toast = Toast.makeText(context, text, duration);
        toast.show();
    }
}
private Bitmap DownloadImage(String url) throws Exception {
    Bitmap bitmap = null;
    InputStream in = null;
    try {
        in = OpenHttpConnection(url);
        bitmap = BitmapFactory.decodeStream(in);
        in.close();
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    return bitmap;
}
private InputStream OpenHttpConnection(String url) throws Exception {
    InputStream in = null;
    int response = -1;
    System.out.println("Nishi1"); 
    URL url1 = new URL(url); 
    URLConnection conn = url1.openConnection();
    if (!(conn instanceof HttpURLConnection)) 
        throw new IOException("Not an HTTP connection");
    try{
        HttpURLConnection httpConn = (HttpURLConnection) conn;
        httpConn.setAllowUserInteraction(false);
        httpConn.setInstanceFollowRedirects(true);
        httpConn.setRequestMethod("GET");
        httpConn.connect(); 
        response = httpConn.getResponseCode(); 
        if (response == HttpURLConnection.HTTP_OK) {
            in = httpConn.getInputStream(); 
            System.out.println(in);
        } 
    }
    catch (Exception ex)
    {
        throw new IOException("Error connecting"); 
    }
    return in; 
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T01:09:22+00:00Added an answer on June 10, 2026 at 1:09 am

    So I want to add a loading bar or progress bar

    For your approach you need to use Threads. Especially i recommend to you have look at

    • Handler
    • AsyncTask

    Both approaches offer work with Threads. AsyncTask is more complex than Handler also it’s generic-type so offer more type-safe and faster work.

    You should read some tutorials so

    • ProgressBar updating using Message Handler
    • Create A Custom Progress Bar Using
      AsyncTask

    And there is very awesome and useful tutorial at Vogella

    • Android Threads, Handlers and AsyncTask -
      Tutorial
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom class which I want to load inside the firstViewController and
I have various class which perform save and update operations of GUI elements, it
I have a file input element which generate by ajax/jquery.load(). and when I want
I have several classes that need to load some properties files, and I was
I have an ASP.NET website in which I am loading some validation rules from
I have some rb files, all with the same structure: class RandomName < FooBar
I have class which have one public method Start , one private method and
I have class LegacyClass which inherits OldBaseClass. I'm considering a change to introduce a
I have class Money which is an @Embeddable @Embeddable public class Money implements Serializable,
I have class A which extends the Activity class. This class is in package

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.