getSelectedText在非活动的InputConnection / setComposingText上非活动的InputConnection / getExtractedText在非活动的InputConnection上

时间:2013-05-08 20:26:11

标签: android android-emulator

这是我的连接android app到pc服务器中包含的外部数据库的代码!!我的应用程序在日食的模拟器中工作得非常好,但是当我在我的三星Galaxy s2中使用该应用程序时无效!当我尝试在EditText中写入时,logCat说:

05-08 21:54:25.800: W/IInputConnectionWrapper(876): getSelectedText on inactive InputConnection 05-08 21:54:25.805: W/IInputConnectionWrapper(876): setComposingText on inactive InputConnection 05-08 21:54:25.805: W/IInputConnectionWrapper(876): getExtractedText on inactive InputConnection

公共类MainActivity扩展了Activity {

 EditText username1;
 EditText password1;
 TextView status;
 ResultSet rs;

//private static final String url = "jdbc:mysql://10.0.2.2:3306/tesina";
private static final String url = "jdbc:mysql://192.168.1.10:3306/tesina";
private static final String user = "root";
private static final String pass = "";

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    username1 = (EditText) findViewById(R.id.user);
    password1 = (EditText) findViewById(R.id.pass);

    //status =(TextView) findViewById(R.id.login_error);
    Button btnLogin=(Button) findViewById(R.id.btnlogin);
     btnLogin.setOnClickListener(new View.OnClickListener() {

         public void onClick(View view) {


             new Connessione().execute();

          }
     });
 }

 private class Connessione extends AsyncTask<String, String, Void> {

            @Override
            protected Void doInBackground(String... String) {
                String us = username1.getText().toString();




                try {

                    Class.forName("com.mysql.jdbc.Driver");
                    Connection con = DriverManager.getConnection(url, user, pass);
                    Statement stmt = con.createStatement();
                   rs = (ResultSet) stmt.executeQuery("SELECT * FROM prova WHERE nome='"+us+"'");
                }
                catch(Exception e) {
                    e.printStackTrace();

                }   
                return null;
                }
           protected void onProgressUpdate(String... values) {

            }


            protected void onPostExecute(String result) {

            String p = password1.getText().toString();
               try {

                if(rs.next())
                   {  
                       String dbpass = rs.getString(2);
                       if(dbpass.equals(p))
                       {

                           Intent i = new Intent(MainActivity.this,classi.class);
                           i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                           startActivity(i);
                          finish();

                       }
                   else
                   {

                      Toast.makeText(getBaseContext(), "errore: password non inserita correttamente", Toast.LENGTH_LONG).show();


                   }
                  }
                   else
                   {
                       Toast.makeText(getBaseContext(), "errore:username non trovato", Toast.LENGTH_LONG).show();


                   }
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                Toast.makeText(getBaseContext(), "applicazione non collegata al database della scuola", Toast.LENGTH_LONG).show();
            }

            }
            }

}

`

0 个答案:

没有答案