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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:31:19+00:00 2026-06-18T11:31:19+00:00

package com.example.friendfinder; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse;

  • 0
    package com.example.friendfinder;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class login extends Activity implements OnClickListener{

    String APIurl = "http://friendfinder.hostzi.com/ws/";
    Button btnlogin;
    TextView login_user;
    TextView login_pass;
    TextView tv;
    JSONObject jObject;
    AlertDialog.Builder builder;
    AlertDialog alert;
    ProgressDialog progressDialog;

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);
        start();
    }

    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.btn_entrar:
            if (checkStatus()) {
                progressDialog.show();
                new Thread(new Runnable() {

                    public void run() {
                        try {
                            jObject = new JSONObject(getJSON("login.php?email="
                                    + login_user.getText().toString()
                                    + "&password="
                                    + login_pass.getText().toString()));
                            tv.setText(jObject.toString());
                            Log.e("JSON", jObject.toString());
                            if (jObject.getString("success").equalsIgnoreCase(
                                    "true")) {
                                progressDialog.dismiss();
                                confirm();
                            } else if (jObject.getString("success")
                                    .equalsIgnoreCase("false")) {
                                login.this.runOnUiThread(new Runnable() {

                                    @Override
                                    public void run() {
                                        progressDialog.dismiss();
                                        builder.setMessage("O inicio de sessão falhou, verifica os teus dados.");
                                        alert = builder.create();
                                        alert.show();
                                    }

                                });
                                login.this.runOnUiThread(null);

                            } else {
                                login.this.runOnUiThread(new Runnable() {

                                    @Override
                                    public void run() {
                                        progressDialog.dismiss();
                                        builder.setMessage("O inicio de sessão falhou, verifica os teus dados.");
                                        alert = builder.create();
                                        alert.show();
                                    }

                                });
                                login.this.runOnUiThread(null);
                            }
                        } catch (JSONException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }

                    }
                }).start();
            }
            else{
                builder.setMessage("Não existe de momento nenhuma conexão à Internet! O ínicio de sessão é impossivel de realizar");
                alert = builder.create();
                alert.show();
            }
        }
    }

    public void start(){
        login_user = (TextView) findViewById(R.id.login_user);
        login_pass = (TextView) findViewById(R.id.login_pass);
        tv = (TextView) findViewById(R.id.tv);
        btnlogin = (Button) findViewById(R.id.btn_entrar);
        btnlogin.setOnClickListener(this);
        progressDialog = new ProgressDialog(this);
        progressDialog.setMessage("A iniciar sessão...");
        builder = new AlertDialog.Builder(login.this);
        builder.setCancelable(false);
        builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });
    }

    public void confirm(){
        Intent i = new Intent(login.this, maps.class);
        startActivity(i);
        finish();
    }

    public String getJSON(String rurl) {
        StringBuilder builder = new StringBuilder();
        HttpClient client = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(APIurl + rurl);
        try {
            HttpResponse response = client.execute(httpGet);
            StatusLine statusLine = response.getStatusLine();
            int statusCode = statusLine.getStatusCode();
            if (statusCode == 200) {
                HttpEntity entity = response.getEntity();
                InputStream content = entity.getContent();
                BufferedReader reader = new BufferedReader(
                        new InputStreamReader(content));
                String line;
                while ((line = reader.readLine()) != null) {
                    builder.append(line);
                }
            } else {

            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return builder.toString();
    }

    public boolean checkStatus() {
        ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo netInfo = cm.getActiveNetworkInfo();
        if (netInfo != null && netInfo.isConnectedOrConnecting()) {
            return true;
        }
        return false;
    }

}

LogCat
http://pastebin.com/0xVv2pBR

When i click the button to login the app crashes and i realy can’t understand what is wrong, if you need more information just ask me. If you know how to resolve help me please.
Thanks

  • 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-18T11:31:21+00:00Added an answer on June 18, 2026 at 11:31 am

    logs says

    “02-06 18:50:47.785: I/Choreographer(874): Skipped 41 frames! The application may be doing too much work on its main thread”

    if you are new to Android you must learn to implement AsyncTask in your Activity. You are not suppose to use webservice or http communication in main/UI thread. here i found Tutorial to implement AsyncTask please learn it will solve your problem.

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

Sidebar

Related Questions

package com.example.application; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import org.jsoup.Jsoup; import org.jsoup.nodes.Document;
I have the following classes: Main.java package com.example.webapp; import org.json.JSONException; import org.json.JSONObject; import android.app.Activity;
here is my Code package com.example.messenger; import java.io.IOException; import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetAddress;
The code is also at https://github.com/timp21337/java-generics-example package a; import java.util.List; public interface Container<T> {
1st activity package com.example.parserss; import java.net.URL; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.InputSource; import org.xml.sax.XMLReader;
i have the following piece of code : package com.example.task; import java.util.List; import android.os.Bundle;
package com.example.temp_application; import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.widget.ArrayAdapter; import android.widget.EditText;
Main Activity Code. BroadcastExample.java package com.example.broadcast; import android.app.Activity; import android.os.Bundle; import android.util.Log; public class
Here is My Whole Code....... BroadcastExample.java package com.example.broadcast; > import android.app.Activity; import > android.content.Context;
package com.example.test3; import java.util.HashMap; import android.os.Bundle; import android.app.Activity; import android.app.AlertDialog; import android.app.DialogFragment; import android.app.FragmentManager;

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.