• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps app won't open browser

kevinypc

Lurker
I have a simple app (less than 20 lines of code) that grabs the Latitude/Longitude and redirects the user to a website (there is no UI to the app besides the splash screen).

Code:
 public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    
    
    Thread splashTread = new Thread() 
    {
        @Override
        public void run() {
            try
            {
                int waited = 0;
                getPresentLocation();
                
                //Loop for 5 seconds to try and get the Latitude and Longitude coords
                while(_active && (waited < 5000)) 
                {
                    sleep(100);
                    if(_active) 
                    {
                        waited += 100;
                    }
                    
                    //If the latitude and Longitude is found, stop the loop
                    if(!Double.isNaN(Long) && !Double.isNaN(Lat))
                    {
                        _active = false;
                        waited += 5000;
                    }
                }
            } 
            catch(InterruptedException e){}
            finally 
            {
                //Create the mobile URL
                String myUrl = "http://www.mysite.mobi/?lat="+Lat+"&long="+Long;
                if(Double.isNaN(Lat) && Double.isNaN(Long))
                {
                    myUrl = "http://www.mysite.mobi";
                }
                

                finish();
                
                //Launch web browser                    
                Uri uri = Uri.parse(myUrl);
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                startActivity(intent);
            }
        }
    };
    splashTread.start();
}


So what happens is, when you launch the app, the splash screen appears for about 5 seconds as intended, then it closes and you are brought to your launchers main page. The browser never opens BUT if you go launch the browser, it opens to the URL my app sets. It seems like my app is sending the URL to the browser but doesn't bring it to focus.

I was able to reproduce this on 4 different phones, running 2.1, 2.3.3, 2.3.6, and 4.0. As well as 3 tablets running 3.0 and 4.0


any idea why this would be happening?
 
Back
Top Bottom