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

  • Home
  • SEARCH
  • 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 8210289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:01:21+00:00 2026-06-07T10:01:21+00:00

this is my first official and finished app…or so i thought…here are some of

  • 0

this is my first official and finished app…or so i thought…here are some of my issues (i will post code too):

  1. when loading the app, it takes about 3 – 6 seconds for the ui to even come up…all it shows is the title

  2. i have a progressbar view that i make visible while loading the next picture… that never gets made visible.

  3. when you click on the next or previous buttons, the button stays pressed until it loads

These issues are driving me nuts…who can point me in the right direction

Main.XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    android:id="@+id/widget210"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="0dp" 
        android:layout_weight="1">
        <ImageView
            android:id="@+id/ImageView01"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />
        <ProgressBar
            android:indeterminate="true"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/progressBar1"
            style="?android:attr/progressBarStyleLarge" />
        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:text="Medium Text "
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:ellipsize="end"
            android:maxLines="2"
            android:textColor="#88ffffff"
            android:background="#88000000" android:gravity="center"/>
    </RelativeLayout>
    <TableLayout
        android:id="@+id/widget214"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <TableRow
            android:id="@+id/widget215"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <Button
                android:id="@+id/Previous"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight=".5"
                android:text="Previous" 
                android:onClick="GetPrevPic"/>
            <Button
                android:id="@+id/Next"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight=".5"
                android:text="Next" 
                android:onClick="GetNextPic"/>
        </TableRow>
    </TableLayout>
    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="xxxxxxxxxxxxxxx"
        ads:loadAdOnCreate="true"/>
</LinearLayout>

Java

package com.ndai.funnys;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.*;
import android.widget.*;
import com.google.ads.*;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.w3c.dom.*;


public class GuysFunnysActivity extends Activity 
{
    String xml;
    Document doc;
    NodeList nodes;
    int iIndex = 0;
    int iTotal = 0;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        GetXMLStuff();
        GetPic();
        CheckForUpdates();
        CheckForReferral();
    }
    public void GetXMLStuff()
    {
        xml = XMLfunctions.getXML();
        doc = XMLfunctions.XMLfromString(xml);
        nodes = doc.getElementsByTagName("item");
        iTotal = nodes.getLength();
    }
    public void CheckForReferral()
    {
        SharedPreferences settings = getSharedPreferences("GuysFunnys", 0);
        SharedPreferences.Editor editor = settings.edit();
        long loads = settings.getLong("Loads", 0);
        if (loads % 50 == 0)
        {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setMessage("Thank you for using Guy's Funnys. Our app is only know to those who use it (it isn't in the Play Store). Please send a link for it to your friends. Send link now?")
                .setCancelable(false)
                .setPositiveButton("Yes", new DialogInterface.OnClickListener() 
                {
                    public void onClick(DialogInterface dialog, int id) 
                    {
                        Intent ii=new Intent(android.content.Intent.ACTION_SEND);
                        ii.setType("text/plain");
                        ii.putExtra(Intent.EXTRA_SUBJECT, "Share Guy's Funnys App");
                        ii.putExtra(Intent.EXTRA_TEXT, "I wanted to share this cool app with you - Guy's Funnys - https://sites.google.com/site/guysfunnysapp/Guys%20Funnys.apk");
                        startActivity(Intent.createChooser(ii, "Share Guy's Funnys App"));
                    }
                })
                .setNegativeButton("No", new DialogInterface.OnClickListener() 
                {
                    public void onClick(DialogInterface dialog, int id) 
                    {
                        dialog.cancel();
                    }
                });
            AlertDialog alert = builder.create();
            alert.show();
        }
        editor.putLong("Loads",(loads + 1));
        editor.commit();
    }
    public void CheckForUpdates()
    {
        PackageInfo pInfo;
        try 
        {
            pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
            int s = pInfo.versionCode;
            DefaultHttpClient httpClient = new DefaultHttpClient();
            HttpPost httpPost = new HttpPost("https://sites.google.com/site/guysfunnysapp/appversion.txt");
            HttpResponse httpResponse = httpClient.execute(httpPost);
            HttpEntity httpEntity = httpResponse.getEntity();
            String line = EntityUtils.toString(httpEntity);
            if (Long.valueOf(line) > s)
            {
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setMessage("A new verison of Guy's Funnys is ready to download. The older verisons will not work. Download Now?")
                    .setCancelable(false)
                    .setPositiveButton("Yes", new DialogInterface.OnClickListener() 
                    {
                        public void onClick(DialogInterface dialog, int id) 
                        {
                            Update("https://sites.google.com/site/guysfunnysapp/Guys%20Funnys.apk");
                        }
                    })
                    .setNegativeButton("No", new DialogInterface.OnClickListener() 
                    {
                        public void onClick(DialogInterface dialog, int id) 
                        {
                            finish();
                        }
                    });
                AlertDialog alert = builder.create();
                alert.show();
            }
        } 
        catch (NameNotFoundException e) 
        {
            e.printStackTrace();
        } 
        catch (ClientProtocolException e) 
        {
            e.printStackTrace();
        } 
        catch (IOException e) 
        {
            e.printStackTrace();
        }
    }
    public void Update(String apkurl)
    {
        try 
        {
            URL url = new URL(apkurl);
            HttpURLConnection c = (HttpURLConnection) url.openConnection();
            c.setRequestMethod("GET");
            c.setDoOutput(true);
            c.connect();
            String PATH = Environment.getExternalStorageDirectory() + "/download/";
            File file = new File(PATH);
            file.mkdirs();
            File outputFile = new File(file, "app.apk");
            FileOutputStream fos = new FileOutputStream(outputFile);
            InputStream is = c.getInputStream();
            byte[] buffer = new byte[1024];
            int len1 = 0;
            while ((len1 = is.read(buffer)) != -1) 
            {
                fos.write(buffer, 0, len1);
            }
            fos.close();
            is.close();
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/download/" + "app.apk")), "application/vnd.android.package-archive");
            startActivity(intent);  
        } 
        catch (IOException e) 
        {
            Toast.makeText(getApplicationContext(), "Update error!", Toast.LENGTH_LONG).show();
        }
    }  
    @Override
    public boolean onCreateOptionsMenu(Menu menu)
    {
        menu.add(1, 1, 0, "View Page").setIcon(R.drawable.pageico);
        menu.add(1, 2, 1, "Share Pic").setIcon(R.drawable.shareico);
        menu.add(1, 3, 2, "Share App").setIcon(R.drawable.shareico);
        menu.add(1, 4, 2, "Exit").setIcon(R.drawable.exitico);
        return true;
    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item)
    {
        Element e = (Element)nodes.item(iIndex);
        switch(item.getItemId())
        {
            case 1:
                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(XMLfunctions.getValue(e, "link")));
                startActivity(browserIntent);
                return true;
            case 2:
                Intent i=new Intent(android.content.Intent.ACTION_SEND);
                i.setType("text/plain");
                i.putExtra(Intent.EXTRA_SUBJECT, "Guy's Funnys");
                i.putExtra(Intent.EXTRA_TEXT, XMLfunctions.getValue(e, "guid"));
                startActivity(Intent.createChooser(i, "Guy's Funnys"));
                return true;
            case 3:
                Intent ii=new Intent(android.content.Intent.ACTION_SEND);
                ii.setType("text/plain");
                ii.putExtra(Intent.EXTRA_SUBJECT, "Share Guy's Funnys App");
                ii.putExtra(Intent.EXTRA_TEXT, "I wanted to share this cool app with you - Guy's Funnys - https://sites.google.com/site/guysfunnysapp/Guys%20Funnys.apk");
                startActivity(Intent.createChooser(ii, "Share Guy's Funnys App"));
                return true;
            case 4:
                finish();
                return true;
        }
        return super.onOptionsItemSelected(item);
    }
    public void GetNextPic(View view)
    {
        iIndex++;
        if (iIndex == iTotal)
        {
            iIndex--;
            Toast.makeText(this, "At last photo", Toast.LENGTH_LONG).show(); 
        }
        else
        {
            GetPic();
            AdView adView = (AdView)this.findViewById(R.id.adView);
            adView.loadAd(new AdRequest());
        }
    }
    public void GetPrevPic(View view)
    {
        iIndex--;
        if (iIndex == -1)
        {
            iIndex++;
            Toast.makeText(this, "At first photo", Toast.LENGTH_LONG).show(); 
        }
        else
        {
            GetPic();
            AdView adView = (AdView)this.findViewById(R.id.adView);
            adView.loadAd(new AdRequest());
        }
    }
    public void ShowDebug(View v)
    {
    }   
    public void GetPic()
    {
        ProgressBar progressBar = (ProgressBar) this.findViewById(R.id.progressBar1);
        progressBar.setVisibility(View.VISIBLE);
        ImageView imgView =(ImageView)findViewById(R.id.ImageView01);
        TextView txtView =(TextView)findViewById(R.id.textView1);
        if (iTotal==0)
        {
            txtView.setText("Network Error");
            Toast.makeText(this, "Error connecting to server. Try again later", Toast.LENGTH_LONG).show();
        }
        else
        {
            Element e = (Element)nodes.item(iIndex);
            txtView.setText(XMLfunctions.getValue(e, "title"));
            Drawable drawable = LoadImageFromWebOperations(XMLfunctions.getValue(e, "guid"));
            imgView.setImageDrawable(drawable);
        }
        progressBar.setVisibility(View.INVISIBLE);
    }
    private Drawable LoadImageFromWebOperations(String url)
    {
        try
        {
            InputStream is = (InputStream) new URL(url).getContent();
            Drawable d = Drawable.createFromStream(is, "src name");
            return d;
        }
        catch (Exception e) 
        {
            System.out.println("Exc="+e);
            return null;
        }
    }
}
  • 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-07T10:01:22+00:00Added an answer on June 7, 2026 at 10:01 am

    It looks like you are making network connections, ex: checkForUpdates(), on the main UI Thread. Making network connections should be done with the help of a background Thread. AsyncTask will make this easier for you. Right now, as it is, you are tying up your UI Thread which is creating “lag” issues with your UI.

    http://developer.android.com/reference/android/os/AsyncTask.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my first post here and i like to thank all the people
This can be easily repeated on the official examples here: http://www.jacklmoore.com/colorbox/example1/ Open the first
How to create in-app step by step instructions? Like this ( first boot android
Code first: '''this is main structure of my program''' from twisted.web import http from
i'm new to this kind of things. Kinda the first post ever regarding programming,
This is probably an easy fix, but I'm stumped. Here's the URL: http://urgent.mchenry.edu First
I'm learning about deadlocks in Java, and there's this sample code from Sun's official
This is my first post and I am quite noobish! Please excuse the unsavvyness
I I have read this url first official and this another blog But they
This first bit works: $my_id = 617; $post_id_7 = get_post($my_id); $title = $post_id_7->post_excerpt; echo

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.