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 7765423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:09:47+00:00 2026-06-01T15:09:47+00:00

I’m writing an application that displays Google Map right after the login screen. The

  • 0

I’m writing an application that displays Google Map right after the login screen.
The Build Target is set to 2.3 and my devices run:

1) Samsung Galaxy Ace (2.3.4)
2) Motorolla Xoom (3.1)

I try my app on the Android emulator and it runs fine. Login and map display.

When I connected both devices via USB on my computer and selected them to run the application (note: there was an orange warning sign next to the build target when selecting), the login screen appears just fine and when I click “Sign In” the application crashes on Motorolla and freezes and for a while and then does nothing on my Galaxy Ace.

Note that they can both connect to the internet.

Logcat for the devices while running the app through USB connection:

1) Samsung Galaxy Ace

04-06 00:24:21.599: I/InputReader(162): dispatchTouch::touch event's action is 0
04-06 00:24:21.599: I/InputDispatcher(162): Delivering touch to current input target: action: 0, channel '40796920 com.cylbs.android/com.cylbs.android.MainActivity (server)'
04-06 00:24:21.699: I/InputReader(162): dispatchTouch::touch event's action is 1
04-06 00:24:21.699: I/InputDispatcher(162): Delivering touch to current input target: action: 1, channel '40796920 com.cylbs.android/com.cylbs.android.MainActivity (server)'
04-06 00:24:27.709: W/PowerManagerService(162): Timer 0x3->0x3|0x1
04-06 00:24:28.559: D/BatteryService(162): update start
04-06 00:24:28.569: D/BatteryService(162): update start
04-06 00:24:28.579: D/BatteryService(162): update start

2) Motorolla Xoom

04-06 00:27:13.490: D/AndroidRuntime(3163): Shutting down VM
04-06 00:27:13.490: W/dalvikvm(3163): threadid=1: thread exiting with uncaught exception (group=0x40154760)
04-06 00:27:13.510: E/AndroidRuntime(3163): FATAL EXCEPTION: main
04-06 00:27:13.510: E/AndroidRuntime(3163): android.os.NetworkOnMainThreadException
04-06 00:27:13.510: E/AndroidRuntime(3163):     at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1077)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at dalvik.system.BlockGuard$WrappedNetworkSystem.connect(BlockGuard.java:368)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:208)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:431)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at java.net.Socket.connect(Socket.java:901)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:75)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:48)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:304)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:89)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:292)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:274)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:217)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:624)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at com.cylbs.android.MainActivity.tryLogin(MainActivity.java:65)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at com.cylbs.android.MainActivity$1.onClick(MainActivity.java:41)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at android.view.View.performClick(View.java:3110)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at android.view.View$PerformClick.run(View.java:11928)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at android.os.Handler.handleCallback(Handler.java:587)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at android.os.Handler.dispatchMessage(Handler.java:92)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at android.os.Looper.loop(Looper.java:132)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at android.app.ActivityThread.main(ActivityThread.java:4025)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at java.lang.reflect.Method.invokeNative(Native Method)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at java.lang.reflect.Method.invoke(Method.java:491)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
04-06 00:27:13.510: E/AndroidRuntime(3163):     at dalvik.system.NativeStart.main(Native Method)

This is my code for the MainActivity which is only Login and the Home activity which is where the map appears:

MainActivity:

package com.cylbs.android;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {
    private Button login;
    private EditText username, password;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        login = (Button) findViewById(R.id.logIn);
        username = (EditText) findViewById(R.id.username);
        password = (EditText) findViewById(R.id.password);


        login.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                String   mUsername = username.getText().toString();
                String  mPassword = password.getText().toString();

                tryLogin(mUsername, mPassword);

            }
        });
    }

    public boolean tryLogin(String mUsername, String mPassword)
    {           
        HttpURLConnection connection;
        OutputStreamWriter request = null;

            URL url = null;   
            String response = null;         
            String parameters = "username="+mUsername+"&password="+mPassword;   
            final TextView result = (TextView) findViewById(R.id.result);

            try
            {
                url = new URL("http://10.0.2.2/database_test/index.php");
                connection = (HttpURLConnection) url.openConnection();
                connection.setDoOutput(true);
                connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
                connection.setRequestMethod("POST");    

                request = new OutputStreamWriter(connection.getOutputStream());
                request.write(parameters);
                request.flush();
                request.close();            
                String line = "";               
                InputStreamReader isr = new InputStreamReader(connection.getInputStream());
                BufferedReader reader = new BufferedReader(isr);
                StringBuilder sb = new StringBuilder();
                while ((line = reader.readLine()) != null)
                {
                    sb.append(line);
                }
                // Response from server after login process will be stored in response variable.                
                response = sb.toString();
                // You can perform UI operations here
                Toast.makeText(this,"."+ response +".", 0).show();          


                if (response.equals("Success"))
                {
                    Session obj = new Session();
                    obj.setUsername(mUsername);

                    Intent myIntent = new Intent(MainActivity.this, Home.class);
                    startActivity(myIntent);
                    result.setText("Login successful");
                }   
                else
                {
                    result.setText("Login fail. Please try again");
                }
                isr.close();
                reader.close();
            }
            catch(IOException e)
            {
                // Error
            }
            return true;
    }

}

And the Home activity (extends MapActivity)

package com.cylbs.android;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Home extends MapActivity {

    MapController mControl;
    GeoPoint geoP;
    MapView mapV;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.home);

        mapV = (MapView) findViewById(R.id.mapView);
        mapV.displayZoomControls(true);
        mapV.setBuiltInZoomControls(true);

        double lat = 40.8;
        double longi = -96.666;

        geoP = new GeoPoint((int) (lat *1E6), (int) (longi *1E6));

        mControl = mapV.getController();
        mControl.animateTo(geoP);
        mControl.setZoom(13);


        Button emergencies = (Button) findViewById(R.id.emergencyButton);
        emergencies.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent myIntent = new Intent(Home.this, EmergencyList.class);
                Home.this.startActivity(myIntent);
            }
        });
        Button disruptions = (Button) findViewById(R.id.disruptionButton);
        disruptions.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent myIntent2 = new Intent(Home.this, DisruptionList.class);
                startActivity(myIntent2);
            }
        });
    }

    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }
}

Any ideas? Thoughts?
It’s all for now.
Thank you so much.

P.S.
I’m a new android developer.

  • 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-01T15:09:49+00:00Added an answer on June 1, 2026 at 3:09 pm

    In case anyone else has the same issue I think I have found a solution.

    I looked up the error in LogCat:

    04-06 00:27:13.510: E/AndroidRuntime(3163): android.os.NetworkOnMainThreadException
    

    And according to this http://developer.android.com/reference/android/os/NetworkOnMainThreadException.html

    it seems that some (newer) android versions don’t allow internet connection requests in the MainActivity or something like that.

    Even though I was targetting android version 10 (2.3) I still had the error so I changed my project target to version 8 and it seems to work okay now.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build

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.