你好,游客 登录 注册 搜索
背景:
阅读新闻

Android手机通过socket与pc通信

[日期:2012-07-13] 来源:Linux社区  作者:tobacco5648 [字体:大 中 小]

activity_main.xml代码:

  1. <LinearLayout xmlns:Android="http://schemas.android.com/apk/res/android"  
  2.     android:layout_width="match_parent"  
  3.     android:layout_height="match_parent"  
  4.     android:orientation="vertical" >  
  5.   
  6.     <TextView  
  7.         android:layout_width="wrap_content"  
  8.         android:layout_height="wrap_content"  
  9.         android:text="@string/hello_world" />  
  10.       
  11.     <EditText  
  12.         android:id="@+id/edittext"  
  13.         android:layout_width="fill_parent"  
  14.         android:layout_height="wrap_content"  
  15.         android:hint="@string/message" />  
  16.       
  17.     <Button  
  18.         android:id="@+id/button"  
  19.         android:layout_width="fill_parent"  
  20.         android:layout_height="wrap_content"  
  21.         android:text="@string/hello_world" />  
  22.   
  23. </LinearLayout>  

因为此客户端程序要用到网络,所以要在manifest文件中添加权限。

Manifest.xml代码:

  1. <manifest xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     package="com.tobacco.phonetest"  
  3.     android:versionCode="1"  
  4.     android:versionName="1.0" >  
  5.   
  6.     <uses-sdk  
  7.         android:minSdkVersion="8"  
  8.         android:targetSdkVersion="15" />  
  9.     <uses-permission android:name="android.permission.INTERNET"></uses-permission>  
  10.   
  11.     <application  
  12.         android:icon="@drawable/ic_launcher"  
  13.         android:label="@string/app_name"  
  14.         android:theme="@style/AppTheme" >  
  15.         <activity  
  16.             android:name=".MainActivity"  
  17.             android:label="@string/title_activity_main" >  
  18.             <intent-filter>  
  19.                 <action android:name="android.intent.action.MAIN" />  
  20.   
  21.                 <category android:name="android.intent.category.LAUNCHER" />  
  22.             </intent-filter>  
  23.         </activity>  
  24.     </application>  
  25.   
  26. </manifest>  
linux
相关资讯       Android编程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款