Android 6.0,当我生成发布版本

时间:2017-02-04 20:18:59

标签: java android

我开发了一款适用于Android的应用程序,不幸的是,当我尝试编译版本“发布”并安装它不再适用于Android 6.0设备时。通过输入“debugbble true”参数,然而它可以工作,遗憾的是不允许我在playstore上发布它。有没有人有办法解决吗?我还添加了一个活动的吐司启动,不幸的是nonv hyenas甚至作为第一个声明。我能怎么做? 编辑。

    package org.altervista.xsparter.www.IlMaestro001;

import android.accounts.Account;
import android.accounts.AccountManager;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by domen on 24/09/2015.
 */
public class externalcom {
    public String urlgenerale = "http://musicalcentroarte.altervista.org/AppAndroid/Setticlavio/";
    public int errori;
    public int corrette;
    public int livello;
    public String email;
    public String chiavi;
    public boolean httpcontroller = false;
    public boolean getstatus;
    public boolean databaseonline;
    public String action;
    public String nickverifier;
    public String nickname;
    public String SettingNickname;
    public Boolean nickBOOLverifier;


    public static String getEmail(AccountManager account_service) {
        AccountManager manager = account_service;
        Account[] list = manager.getAccounts();
        String gmail = null;

        for (Account account : list) {
            if (account.type.equalsIgnoreCase("com.google")) {
                gmail = account.name;
                break;
            }
        }

        return gmail;
    }

    public Boolean getStatus() throws IOException {
        httpcontroller = false;

        Thread t = new Thread(new Runnable() {
            public void run() {

                final int threadid = (int) Thread.currentThread().getId();
                externalcom externalcom = new externalcom();
                HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost(externalcom.urlgenerale + "getdatabaseacces.php");

                try {
                    // Add your data
                    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
                    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                    // Execute HTTP Post Request
                    HttpResponse response = httpclient.execute(httppost);

                    StringBuilder sb = new StringBuilder();
                    try {
                        BufferedReader reader =
                                new BufferedReader(new InputStreamReader(response.getEntity().getContent()), 65728);
                        String line = null;

                        while ((line = reader.readLine()) != null) {
                            sb.append(line);
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    if (sb.toString().equals("false")) {
                        getstatus = false;
                    } else if (sb.toString().equals("true")) {
                        getstatus = true;
                    }
                    httpcontroller = true;

                } catch (UnknownHostException e) {
                    getstatus = false;
                    httpcontroller = true;
                } catch (IOException e) {
                    getstatus = false;
                    httpcontroller = true;
                }
                Thread.currentThread().interrupt();
            }
        });
        t.start();
        for (int i = 0; httpcontroller == false; i++) {
            sleep(1);
            if (i == 2000) {
                t.interrupt();
                getstatus = false;
                break;
            }
        }
        if (getstatus == true) {
            return true;
        } else {
            return false;
        }


    }

    public Boolean getConnectionStatus() throws IOException {
        Thread t = new Thread(new Runnable() {
            public void run() {

                final int threadid = (int) Thread.currentThread().getId();
                externalcom externalcom = new externalcom();
                HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost(externalcom.urlgenerale + "status.php");

                try {
                    // Execute HTTP Post Request
                    HttpResponse response = httpclient.execute(httppost);

                    StringBuilder sb = new StringBuilder();
                    try {
                        BufferedReader reader =
                                new BufferedReader(new InputStreamReader(response.getEntity().getContent()), 65728);
                        String line = null;

                        while ((line = reader.readLine()) != null) {
                            sb.append(line);
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                        getstatus = false;
                        httpcontroller = true;
                    } catch (Exception e) {
                        e.printStackTrace();
                        getstatus = false;
                        httpcontroller = true;
                    }
                    if (sb.toString().equals("true")) {
                        getstatus = true;
                        httpcontroller = true;
                    } else {
                        getstatus = false;
                        httpcontroller = true;
                    }


                } catch (UnknownHostException e) {
                    getstatus = false;
                    httpcontroller = true;
                } catch (IOException e) {
                    getstatus = false;
                    httpcontroller = true;
                }
                Thread.currentThread().interrupt();
            }
        });
        t.start();
        httpcontroller = false;
        for (int i = 0; httpcontroller == false; i++) {
            sleep(1);
            if (i == 2000) {

                t.interrupt();
                getstatus = false;
                break;
            }
        }
        if (getstatus == true) {
            return true;
        } else {
            return false;
        }


    }

    public Boolean nickIsStoraged(String nicknameTT) throws IOException {
        nickname = nicknameTT;
        httpcontroller = false;
        Thread t = new Thread(new Runnable() {
            public void run() {
                externalcom externalcom = new externalcom();
                HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost(externalcom.urlgenerale + "ifnick.php");
                // Add your data
                List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
                nameValuePairs.add(new BasicNameValuePair("email", email));
                nameValuePairs.add(new BasicNameValuePair("comparenickname", nickname));
                try {
                    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }

                // Execute HTTP Post Request
                HttpResponse response = null;
                try {
                    response = httpclient.execute(httppost);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                StringBuilder sb = new StringBuilder();
                BufferedReader reader =
                        null;
                try {
                    reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()), 65728);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                String line = null;

                try {
                    while ((line = reader.readLine()) != null) {
                        sb.append(line);
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }

                nickverifier = sb.toString();
                nickBOOLverifier = Boolean.parseBoolean(nickverifier);
                httpcontroller = true;
            }
        });
        t.start();
        while (httpcontroller == false) {
        }
        return nickBOOLverifier;
    }

    public Boolean getnickname(String emailT, String nicknameTT, String actionTT) {
        email = emailT;
        nickname = nicknameTT;
        action = actionTT;
        httpcontroller = false;

        //-----------______________---------
        Thread t = new Thread(new Runnable() {
            public void run() {
                externalcom externalcom = new externalcom();
                HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost(externalcom.urlgenerale + "getnick.php");

                try {
                    // Add your data
                    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
                    nameValuePairs.add(new BasicNameValuePair("email", email));
                    if (nickname == null && action == "casual") {
                        //System.err.println("Generazione nick casuale");
                        nameValuePairs.add(new BasicNameValuePair("casual", "true"));
                    } else if (nickname != null && action == null) {
                        nameValuePairs.add(new BasicNameValuePair("nickname", nickname));
                    } else if (nickname == null && action == "getname" && email != null) {
                        nameValuePairs.add(new BasicNameValuePair("foundnick", "true"));
                    } else if (nickname != null && action == "update" && email != null) {
                        nameValuePairs.add(new BasicNameValuePair("update", nickname));
                    }
                    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

                    // Execute HTTP Post Request
                    HttpResponse response = httpclient.execute(httppost);
                    StringBuilder sb = new StringBuilder();
                    try {
                        BufferedReader reader =
                                new BufferedReader(new InputStreamReader(response.getEntity().getContent()), 65728);
                        String line = null;

                        while ((line = reader.readLine()) != null) {
                            sb.append(line);
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                    nickverifier = sb.toString();
                    if (action != "getname") {
                        nickBOOLverifier = Boolean.parseBoolean(nickverifier);
                    } else {
                        SettingNickname = nickverifier;
                        nickBOOLverifier = true;
                    }
                    httpcontroller = true;

                } catch (ClientProtocolException e) {
                    // TODO Auto-generated catch block
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                }
                Thread.currentThread().interrupt();
            }
        });
        t.start();
        while (httpcontroller == false) {

        }
        httpcontroller = false;
        return nickBOOLverifier;
    }

    public void databasememory(int erroriT, int corretteT, int livelloT, String emailT, String chiaviT) {
        errori = erroriT;
        if (errori == 0) {
            errori = 1;
        }
        corrette = corretteT;
        livello = livelloT;
        email = emailT;
        chiavi = chiaviT;
        Thread t = new Thread(new Runnable() {
            public void run() {
                HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost(urlgenerale + "databasewriter.php");

                try {
                    // Add your data
                    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
                    nameValuePairs.add(new BasicNameValuePair("email", email));
                    nameValuePairs.add(new BasicNameValuePair("errori", String.valueOf(errori)));
                    nameValuePairs.add(new BasicNameValuePair("corretti", String.valueOf(corrette)));
                    nameValuePairs.add(new BasicNameValuePair("livello", String.valueOf(livello)));
                    nameValuePairs.add(new BasicNameValuePair("chiavi", chiavi));
                    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

                    // Execute HTTP Post Request
                    HttpResponse response = httpclient.execute(httppost);

                } catch (ClientProtocolException e) {
                    // TODO Auto-generated catch block
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                }
                Thread.currentThread().interrupt();
            }
        });
        t.start();


    }

    public void sleep(int value) {
        try {
            Thread.sleep(value);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

此库导致应用程序冻结,但它仅在android 6.0+上的发布模式下损坏应用程序。有人能解释为什么吗?我需要这个.class ..

0 个答案:

没有答案