douji8347 2012-04-15 23:31
浏览 58

使用“DefaultRequestDirector”和“DefualtHttpCLient”类时Android,Eclipse“找不到源”

I'm trying to create a Login/Register application that uses PHP,MySQL and SQLite to allow users to register via Android as the client. I have my PHP files on my local Apache server. One thing I have run into is an "Access Denied" message when trying to view the "index.php" file on the server. I believe the below config is correct to access my database:

<?php

/**
 * Database config variables
 */
define("DB_HOST", "localhost");
define("DB_USER", "droid");
define("DB_PASSWORD", "");
define("DB_DATABASE", "droidservice");
?>

Does receiving the "Access Denied" message mean my configuration to MySQL database is incorrect?

When I debug the Android application I continue to receive errors saying:

  • "The source attachment does not contain the source for the file DefaultRequestDirector.class"
  • "The source attachment does not contain the source for the file DefaultHttpClient.class"

I'm using a "httpPost" method to access the server and from there parse the JSON. Could the above errors be due to not having the correct http library connected, or some Eclipse config issues?

I've been using the methods primarily from the following tutorial: http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/

  • 写回答

1条回答

  • dongliao4353 2012-04-19 14:34
    关注

    I am talking regarding this tutorial: http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/

    You have done Database setup correctly. In this tutorial "Access Denied" will be shown if you don't pass correct params to index.php file.

    If you observe correctly while login along with username, password parameters you need to pass a param called tag = "login" is passed. In php (index.php) in if condition this tag is checked to detect request type. (login or register)

    Android:

    params.add(new BasicNameValuePair("tag", login_tag));
    

    Php:

    // check for tag type
        if ($tag == 'login') {
    

    If you pass the tag parameter you won't get Access Denied message and your application works perfectly.

    Also while registration you need to pass

    Android:

    params.add(new BasicNameValuePair("tag", register_tag));
    
    评论

报告相同问题?

悬赏问题

  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的