├── .classpath ├── .gitattributes ├── .gitignore ├── .idea └── vcs.xml ├── .project ├── .settings └── org.eclipse.jdt.core.prefs ├── AndroidManifest.xml ├── PHP代码 └── android_connect │ ├── db_config.php │ ├── db_connect.php │ ├── get_all_users.php │ └── test.php ├── README.md ├── bin ├── AndroidManifest.xml ├── PHPForAndroid.apk ├── classes.dex ├── classes │ └── com │ │ └── example │ │ └── phpforandroid │ │ ├── BuildConfig.class │ │ ├── MainActivity.class │ │ ├── R$attr.class │ │ ├── R$drawable.class │ │ ├── R$layout.class │ │ ├── R$string.class │ │ ├── R$style.class │ │ └── R.class ├── dexedLibs │ └── android-support-v4-94a0bf31b1f8e7f923ff792ca8f3464a.jar ├── jarlist.cache ├── res │ └── crunch │ │ ├── drawable-hdpi │ │ └── ic_launcher.png │ │ ├── drawable-mdpi │ │ └── ic_launcher.png │ │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ │ └── drawable-xxhdpi │ │ └── ic_launcher.png └── resources.ap_ ├── gen └── com │ └── example │ └── phpforandroid │ ├── BuildConfig.java │ └── R.java ├── ic_launcher-web.png ├── libs └── android-support-v4.jar ├── proguard-project.txt ├── project.properties ├── res ├── drawable-hdpi │ └── ic_launcher.png ├── drawable-mdpi │ └── ic_launcher.png ├── drawable-xhdpi │ └── ic_launcher.png ├── drawable-xxhdpi │ └── ic_launcher.png ├── layout │ └── activity_main.xml ├── values-v11 │ └── styles.xml ├── values-v14 │ └── styles.xml └── values │ ├── strings.xml │ └── styles.xml └── src └── com ├── example └── phpforandroid │ └── MainActivity.java └── zhy └── utils └── HttpUtils.java /.classpath: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | PHPForAndroid 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /PHP代码/android_connect/db_config.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /PHP代码/android_connect/db_connect.php: -------------------------------------------------------------------------------- 1 | connect(); 6 | } 7 | function __destruct(){ 8 | // $this->close(); 9 | } 10 | public function connect(){ 11 | require_once __DIR__ . '/db_config.php'; 12 | 13 | // Connecting to mysql database 14 | $con = mysqli_connect(DB_SERVER, DB_USER, DB_PASSWORD,DB_DATABASE) or die ("could not connect to mysql"); 15 | if (!$con) 16 | { 17 | echo("连接错误: " ); 18 | } 19 | // Selecing database 20 | //USE DB_DATABASE; 21 | $db = mysqli_select_db($con,"DBTest")or die ("no mysqli_select_db "); 22 | 23 | // returing connection cursor 24 | return $con; 25 | } 26 | 27 | } 28 | ?> -------------------------------------------------------------------------------- /PHP代码/android_connect/get_all_users.php: -------------------------------------------------------------------------------- 1 | connect(),"SELECT *FROM user") or die("mysqli_query"); 11 | $raw=mysqli_fetch_array($result); 12 | $response['name']="liulianhua";//$raw['name']; 13 | $response['age']="1000";//$raw['age']; 14 | // echoing JSON response 15 | echo json_encode($response); 16 | ?> -------------------------------------------------------------------------------- /PHP代码/android_connect/test.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PHPForAndroid 2 | 3 | PHP与MySQL做后台,Android做客户端。小小通信例子。 4 | 5 | # 背景 6 | 7 | 忘记写README的结果就是我现在不知道我写的什么代码,步骤一概不知,23333... 8 | 9 | 我看懂了,其实主要代码是PHP里的一些对数据库的操作 10 | 11 | # 工具 12 | 13 | WAMP:Windows下的Apache+Mysql/MariaDB+Perl/PHP/Python,一组常用来搭建动态网站或者服务器的开源软件 14 | 15 | # 步骤 16 | 17 | 1. db_connect:连接MYSQL数据库 18 | 19 | 2. get_all_users:select * from ... 20 | 21 | # 运行 22 | 23 | 不知道WAMP抽什么风了,打不开,效果运行不了了!其实就是本地动态显示PHP从MySQL获取的个人信息 24 | 25 | # 总结 26 | 27 | 会用PHP写一点简单的后台,是不是很牛逼! 28 | -------------------------------------------------------------------------------- /bin/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /bin/PHPForAndroid.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/bin/PHPForAndroid.apk -------------------------------------------------------------------------------- /bin/classes.dex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/bin/classes.dex -------------------------------------------------------------------------------- /bin/classes/com/example/phpforandroid/BuildConfig.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/bin/classes/com/example/phpforandroid/BuildConfig.class -------------------------------------------------------------------------------- /bin/classes/com/example/phpforandroid/MainActivity.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/bin/classes/com/example/phpforandroid/MainActivity.class -------------------------------------------------------------------------------- /bin/classes/com/example/phpforandroid/R$attr.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/bin/classes/com/example/phpforandroid/R$attr.class -------------------------------------------------------------------------------- /bin/classes/com/example/phpforandroid/R$drawable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/bin/classes/com/example/phpforandroid/R$drawable.class -------------------------------------------------------------------------------- /bin/classes/com/example/phpforandroid/R$layout.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/bin/classes/com/example/phpforandroid/R$layout.class -------------------------------------------------------------------------------- /bin/classes/com/example/phpforandroid/R$string.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/bin/classes/com/example/phpforandroid/R$string.class -------------------------------------------------------------------------------- /bin/classes/com/example/phpforandroid/R$style.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/bin/classes/com/example/phpforandroid/R$style.class -------------------------------------------------------------------------------- /bin/classes/com/example/phpforandroid/R.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/bin/classes/com/example/phpforandroid/R.class -------------------------------------------------------------------------------- /bin/dexedLibs/android-support-v4-94a0bf31b1f8e7f923ff792ca8f3464a.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/bin/dexedLibs/android-support-v4-94a0bf31b1f8e7f923ff792ca8f3464a.jar -------------------------------------------------------------------------------- /bin/jarlist.cache: -------------------------------------------------------------------------------- 1 | # cache for current jar dependency. DO NOT EDIT. 2 | # format is 3 | # Encoding is UTF-8 4 | -------------------------------------------------------------------------------- /bin/res/crunch/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/bin/res/crunch/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /bin/res/crunch/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/bin/res/crunch/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /bin/res/crunch/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/bin/res/crunch/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /bin/res/crunch/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/bin/res/crunch/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /bin/resources.ap_: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/bin/resources.ap_ -------------------------------------------------------------------------------- /gen/com/example/phpforandroid/BuildConfig.java: -------------------------------------------------------------------------------- 1 | /** Automatically generated file. DO NOT MODIFY */ 2 | package com.example.phpforandroid; 3 | 4 | public final class BuildConfig { 5 | public final static boolean DEBUG = true; 6 | } -------------------------------------------------------------------------------- /gen/com/example/phpforandroid/R.java: -------------------------------------------------------------------------------- 1 | /* AUTO-GENERATED FILE. DO NOT MODIFY. 2 | * 3 | * This class was automatically generated by the 4 | * aapt tool from the resource data it found. It 5 | * should not be modified by hand. 6 | */ 7 | 8 | package com.example.phpforandroid; 9 | 10 | public final class R { 11 | public static final class attr { 12 | } 13 | public static final class drawable { 14 | public static final int ic_launcher=0x7f020000; 15 | } 16 | public static final class id { 17 | public static final int tv=0x7f060000; 18 | } 19 | public static final class layout { 20 | public static final int activity_main=0x7f030000; 21 | } 22 | public static final class string { 23 | public static final int app_name=0x7f040000; 24 | public static final int hello_world=0x7f040001; 25 | } 26 | public static final class style { 27 | /** 28 | Base application theme, dependent on API level. This theme is replaced 29 | by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 30 | 31 | 32 | Theme customizations available in newer API levels can go in 33 | res/values-vXX/styles.xml, while customizations related to 34 | backward-compatibility can go here. 35 | 36 | 37 | Base application theme for API 11+. This theme completely replaces 38 | AppBaseTheme from res/values/styles.xml on API 11+ devices. 39 | 40 | API 11 theme customizations can go here. 41 | 42 | Base application theme for API 14+. This theme completely replaces 43 | AppBaseTheme from BOTH res/values/styles.xml and 44 | res/values-v11/styles.xml on API 14+ devices. 45 | 46 | API 14 theme customizations can go here. 47 | */ 48 | public static final int AppBaseTheme=0x7f050000; 49 | /** Application theme. 50 | All customizations that are NOT specific to a particular API-level can go here. 51 | */ 52 | public static final int AppTheme=0x7f050001; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/ic_launcher-web.png -------------------------------------------------------------------------------- /libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/libs/android-support-v4.jar -------------------------------------------------------------------------------- /proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-19 15 | -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 14 | 15 | -------------------------------------------------------------------------------- /res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | PHPForAndroid 5 | Hello world! 6 | 7 | 8 | -------------------------------------------------------------------------------- /res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/com/example/phpforandroid/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.phpforandroid; 2 | 3 | import com.zhy.utils.HttpUtils; 4 | import com.zhy.utils.HttpUtils.CallBack; 5 | 6 | import android.app.Activity; 7 | import android.gesture.GestureOverlayView; 8 | import android.os.Bundle; 9 | import android.view.Menu; 10 | import android.view.MenuItem; 11 | import android.view.View; 12 | import android.widget.Button; 13 | import android.widget.TextView; 14 | 15 | public class MainActivity extends Activity { 16 | private TextView tv; 17 | 18 | @Override 19 | protected void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | setContentView(R.layout.activity_main); 22 | tv = getViewById(R.id.tv); 23 | HttpUtils.doGetAsyn("http://10.0.3.2/android_connect/get_all_users.php", new CallBack() { 24 | 25 | @Override 26 | public void onRequestComplete(String result) { 27 | // TODO Auto-generated method stub 28 | tv.setText(result); 29 | } 30 | }); 31 | 32 | } 33 | 34 | public T getViewById(int id) { 35 | return (T) findViewById(id); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/com/zhy/utils/HttpUtils.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stuhua/PHPForAndroid/2fc555088cc8f6d21b1fde43ef8f36e312e9bba5/src/com/zhy/utils/HttpUtils.java --------------------------------------------------------------------------------