首页 文章 精选 留言 我的

精选列表

搜索[网站开发],共10000篇文章
优秀的个人博客,低调大师

Android开发实践:常用NDK命令行参数

Android提供了NDK工具,用来编译native代码(c/c++),该工具配置好了相关的交叉编译环境和工具链,只需要你简单地编写几个.mk文件即可将你的c/c++代码编译为Android的java工程/Android手机可以识别、加载和运行的库或者应用程序。 默认情况下,使用NDK编译c/c++代码,需要将该代码放置到任一个Android应用工程的jni目录下,然后编写相应的Android.mk文件,并执行ndk-build命令完成编译。其实你也是可以在任意目录下去编译native代码的,只需要在ndk-build命令后面添加相应的命令行参数即可,这里给出一些常用的ndk-build命令行参数,方便大家灵活地使用NDK编译自己的native代码,具体的示例我将会在后续的文章中给出。 1. ndk-build NDK_LOG=1 用于配置LOG级别,打印ndk编译时的详细输出信息2. ndk-build NDK_PROJECT_PATH=. 指定NDK编译的代码路径为当前目录,如果不配置,则必须把工程代码放到Android工程的jni目录下3. ndk-build APP_BUILD_SCRIPT=./Android.mk 指定NDK编译使用的Android.mk文件4. ndk-build NDK_APP_APPLICATION_MK=./Application.mk 指定NDK编译使用的application.mk文件5. ndk-build clean 清除所有编译出来的临时文件和目标文件6. ndk-build -B 强制重新编译已经编译完成的代码7. ndk-build NDK_DEBUG=1 执行 debug build8. ndk-build NDK_DEBUG=0 执行 release build9. ndk-build NDK_OUT=./mydir 指定编译生成的文件的存放位置10. ndk-build -C /opt/myTest/ 到指定目录编译native代码 本文转自 Jhuster 51CTO博客,原文链接:http://blog.51cto.com/ticktick/1425857,如需转载请自行联系原作者

优秀的个人博客,低调大师

Android开发学习笔记:数据存取之SQLite浅析

一.SQLite的介绍 1.SQLite简介 SQLite是一款轻型的数据库,是遵守ACID的关联式数据库管理系统,它的设计目标是嵌入 式的,而且目前已经在很多嵌入式产品中使用了它,它占用资源非常的低,在嵌入式设备中,可能只需要几百K的内存就够了。它能够支持 Windows/Linux/Unix等等主流的操作系统,同时能够跟很多程序语言相结合,比如Tcl、PHP、Java、C++、.Net等,还有ODBC接口,同样比起 Mysql、PostgreSQL这两款开源世界著名的数据库管理系统来讲,它的处理速度比他们都快。 2.SQLite的特点: 轻量级 SQLite和C/S模式的数据库软件不同,它是进程内的数据库引擎,因此不存在数据库的客户端和服务器。使用SQLite一般只需要带上它的一个动态 库,就可以享受它的全部功能。而且那个动态库的尺寸也挺小,以版本3.6.11为例,Windows下487KB、Linux下347KB。 不需要"安装" SQLite的核心引擎本身不依赖第三方的软件,使用它也不需要"安装"。有点类似那种绿色软件。 单一文件 数据库中所有的信息(比如表、视图等)都包含在一个文件内。这个文件可以自由复制到其它目录或其它机器上。 跨平台/可移植性 除了主流操作系统 windows,linux之后,SQLite还支持其它一些不常用的操作系统。 弱类型的字段 同一列中的数据可以是不同类型 开源 这个相信大家都懂的! 3.SQLite数据类型 一般数据采用的固定的静态数据类型,而SQLite采用的是动态数据类型,会根据存入值自动判断。SQLite具有以下五种常用的数据类型: NULL: 这个值为空值 VARCHAR(n):长度不固定且其最大长度为 n 的字串,n不能超过 4000。 CHAR(n):长度固定为n的字串,n不能超过 254。 INTEGER: 值被标识为整数,依据值的大小可以依次被存储为1,2,3,4,5,6,7,8. REAL: 所有值都是浮动的数值,被存储为8字节的IEEE浮动标记序号. TEXT: 值为文本字符串,使用数据库编码存储(TUTF-8, UTF-16BE or UTF-16-LE). BLOB: 值是BLOB数据块,以输入的数据格式进行存储。如何输入就如何存储,不改 变格式。 DATA :包含了 年份、月份、日期。 TIME:包含了 小时、分钟、秒。 相信学过数据库的童鞋对这些数据类型都不陌生的!!!!!!!!!! 二.SQLiteDatabase的介绍 Android提供了创建和是用SQLite数据库的API。SQLiteDatabase代表一个数据库对象,提供了操作数据库的一些方法。在Android的SDK目录下有sqlite3工具,我们可以利用它创建数据库、创建表和执行一些SQL语句。下面是SQLiteDatabase的常用方法。 SQLiteDatabase的常用方法 方法名称 方法描述 openOrCreateDatabase(String path,SQLiteDatabase.CursorFactory factory) 打开或创建数据库 insert(String table,String nullColumnHack,ContentValues values) 添加一条记录 delete(String table,String whereClause,String[] whereArgs) 删除一条记录 query(String table,String[] columns,String selection,String[] selectionArgs,String groupBy,String having,String orderBy) 查询一条记录 update(String table,ContentValues values,String whereClause,String[] whereArgs) 修改记录 execSQL(String sql) 执行一条SQL语句 close() 关闭数据库 1、打开或者创建数据库 在Android 中以使用SQLiteDatabase的静态方法openOrCreateDatabase(String path,SQLiteDatabae.CursorFactory factory)打开或者创建一个数据库。它会自动去检测是否存在这个数据库,如果存在则打开,不存在则创建一个数据库;创建成功则返回一个SQLiteDatabase对象,否则抛出异常FileNotFoundException。 下面是创建名为“stu.db”数据库的代码: db=SQLiteDatabase.openOrCreateDatabase("/data/data/com.lingdududu.db/databases/stu.db",null); 2、创建表 创建一张表很简单。首先,编写创建表的SQL语句,然后,调用SQLiteDatabase的execSQL()方法来执行SQL语句便可以创建一张表了。 下面的代码创建了一张用户表,属性列为:_id(主键并且自动增加)、sname(学生姓名)、snumber(学号) privatevoidcreateTable(SQLiteDatabasedb){ //创建表SQL语句 Stringstu_table="createtableusertable(_idintegerprimarykeyautoincrement,snametext,snumbertext)"; //执行SQL语句 db.execSQL(stu_table); } 3、插入数据 插入数据有两种方法: ①SQLiteDatabase的insert(String table,String nullColumnHack,ContentValues values)方法,参数一是表名称,参数二是空列的默认值,参数三是ContentValues类型的一个封装了列名称和列值的Map; ②编写插入数据的SQL语句,直接调用SQLiteDatabase的execSQL()方法来执行 第一种方法的代码: privatevoidinsert(SQLiteDatabasedb){ //实例化常量值 ContentValuescValue=newContentValues(); //添加用户名 cValue.put("sname","xiaoming"); //添加密码 cValue.put("snumber","01005"); //调用insert()方法插入数据 db.insert("stu_table",null,cValue); } 第二种方法的代码: privatevoidinsert(SQLiteDatabasedb){ //插入数据SQL语句 Stringstu_sql="insertintostu_table(sname,snumber)values('xiaoming','01005')"; //执行SQL语句 db.execSQL(sql); } 4、删除数据 删除数据也有两种方法: ①调用SQLiteDatabase的delete(String table,String whereClause,String[] whereArgs)方法,参数一是表名称,参数二是删除条件,参数三是删除条件值数组; ②编写删除SQL语句,调用SQLiteDatabase的execSQL()方法来执行删除。 第一种方法的代码: privatevoiddelete(SQLiteDatabasedb){ //删除条件 StringwhereClause="_id=?"; //删除条件参数 String[]whereArgs={String.valueOf(2)}; //执行删除 db.delete("stu_table",whereClause,whereArgs); } 第二种方法的代码: privatevoiddelete(SQLiteDatabasedb){ //删除SQL语句 Stringsql="deletefromstu_tablewhere_id=6"; //执行SQL语句 db.execSQL(sql); } 5、修改数据 修改数据有两种方法: ①调用SQLiteDatabase的update(String table,ContentValues values,String whereClause, String[] whereArgs)方法。参数是表名称,参数是更行列ContentValues类型的键值对(Map),参数是更新条件(where字句),参数是更新条件数组。 ②编写更新的SQL语句,调用SQLiteDatabase的execSQL执行更新。 第一种方法的代码: privatevoidupdate(SQLiteDatabasedb){ //实例化内容值 ContentValuesvalues=newContentValues(); //在values中添加内容 values.put("snumber","101003"); //修改条件 StringwhereClause="id=?"; //修改添加参数 String[]whereArgs={String.valuesOf(1)}; //修改 db.update("usertable",values,whereClause,whereArgs); } 第二种方法的代码: privatevoidupdate(SQLiteDatabasedb){ //修改SQL语句 Stringsql="updatestu_tablesetsnumber=654321whereid=1"; //执行SQL db.execSQL(sql); } 6、查询数据 在Android中查询数据是通过Cursor类来实现的,当我们使用SQLiteDatabase.query()方法时,会得到一个Cursor对象,Cursor指向的就是每一条数据。它提供了很多有关查询的方法,具体方法如下: public Cursor query(String table,String[] columns,String selection,String[] selectionArgs,String groupBy,String having,String orderBy,String limit); 各个参数的意义说明: ①table:表名称 ②columns:列名称数组 ③selection:条件字句,相当于where ④selectionArgs:条件字句,参数数组 ⑤groupBy:分组列 ⑥having:分组条件 ⑦orderBy:排序列 ⑧limit:分页查询限制 ⑨Cursor:返回值,相当于结果集ResultSet Cursor是一个游标接口,提供了遍历查询结果的方法,如移动指针方法move(),获得列值方法getString()等. Cursor游标常用方法 方法名称 方法描述 getCount() 获得总的数据项数 isFirst() 判断是否第一条记录 isLast() 判断是否最后一条记录 moveToFirst() 移动到第一条记录 moveToLast() 移动到最后一条记录 move(int offset) 移动到指定记录 moveToNext() 移动到下一条记录 moveToPrevious() 移动到上一条记录 getColumnIndexOrThrow(String columnName) 根据列名称获得列索引 getInt(int columnIndex) 获得指定列索引的int类型值 getString(int columnIndex) 获得指定列缩影的String类型值 下面就是用Cursor来查询数据库中的数据,具体代码如下: privatevoidquery(SQLiteDatabasedb) { //查询获得游标 Cursorcursor=db.query("usertable",null,null,null,null,null,null); //判断游标是否为空 if(cursor.moveToFirst(){ //遍历游标 for(inti=0;i<cursor.getCount();i++){ cursor.move(i); //获得ID intid=cursor.getInt(0); //获得用户名 Stringusername=cursor.getString(1); //获得密码 Stringpassword=cursor.getString(2); //输出用户信息 System.out.println(id+":"+sname+":"+snumber); } } } 7、删除指定表 编写插入数据的SQL语句,直接调用SQLiteDatabase的execSQL()方法来执行 privatevoiddrop(SQLiteDatabasedb){ //删除表的SQL语句 Stringsql="DROPTABLEstu_table"; //执行SQL db.execSQL(sql); } 三.SQLiteOpenHelper 该类是SQLiteDatabase一个辅助类。这个类主要生成一 个数据库,并对数据库的版本进行管理。当在程序当中调用这个类的方法getWritableDatabase()或者 getReadableDatabase()方法的时候,如果当时没有数据,那么Android系统就会自动生成一个数据库。 SQLiteOpenHelper 是一个抽象类,我们通常需要继承它,并且实现里面的3个函数: 1.onCreate(SQLiteDatabase) 在数据库第一次生成的时候会调用这个方法,也就是说,只有在创建数据库的时候才会调用,当然也有一些其它的情况,一般我们在这个方法里边生成数据库表。 2. onUpgrade(SQLiteDatabase,int,int) 当数据库需要升级的时候,Android系统会主动的调用这个方法。一般我们在这个方法里边删除数据表,并建立新的数据表,当然是否还需要做其他的操作,完全取决于应用的需求。 3. onOpen(SQLiteDatabase): 这是当打开数据库时的回调函数,一般在程序中不是很常使用。 写了这么多,改改用实际例子来说明上面的内容了。下面这个操作数据库的实例实现了创建数据库,创建表以及数据库的增删改查的操作。 SQLiteActivity.java packagecom.lingdududu.testSQLite; importcom.lingdududu.testSQLiteDb.StuDBHelper; importandroid.app.Activity; importandroid.content.ContentValues; importandroid.database.Cursor; importandroid.database.sqlite.SQLiteDatabase; importandroid.os.Bundle; importandroid.view.View; importandroid.view.View.OnClickListener; importandroid.widget.Button; /* *@authorlingdududu */ publicclassSQLiteActivityextendsActivity{ /**Calledwhentheactivityisfirstcreated.*/ //声明各个按钮 privateButtoncreateBtn; privateButtoninsertBtn; privateButtonupdateBtn; privateButtonqueryBtn; privateButtondeleteBtn; privateButtonModifyBtn; @Override publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); //调用creatView方法 creatView(); //setListener方法 setListener(); } //通过findViewById获得Button对象的方法 privatevoidcreatView(){ createBtn=(Button)findViewById(R.id.createDatabase); updateBtn=(Button)findViewById(R.id.updateDatabase); insertBtn=(Button)findViewById(R.id.insert); ModifyBtn=(Button)findViewById(R.id.update); queryBtn=(Button)findViewById(R.id.query); deleteBtn=(Button)findViewById(R.id.delete); } //为按钮注册监听的方法 privatevoidsetListener(){ createBtn.setOnClickListener(newCreateListener()); updateBtn.setOnClickListener(newUpdateListener()); insertBtn.setOnClickListener(newInsertListener()); ModifyBtn.setOnClickListener(newModifyListener()); queryBtn.setOnClickListener(newQueryListener()); deleteBtn.setOnClickListener(newDeleteListener()); } //创建数据库的方法 classCreateListenerimplementsOnClickListener{ @Override publicvoidonClick(Viewv){ //创建StuDBHelper对象 StuDBHelperdbHelper=newStuDBHelper(SQLiteActivity.this,"stu_db",null,1); //得到一个可读的SQLiteDatabase对象 SQLiteDatabasedb=dbHelper.getReadableDatabase(); } } //更新数据库的方法 classUpdateListenerimplementsOnClickListener{ @Override publicvoidonClick(Viewv){ //数据库版本的更新,由原来的1变为2 StuDBHelperdbHelper=newStuDBHelper(SQLiteActivity.this,"stu_db",null,2); SQLiteDatabasedb=dbHelper.getReadableDatabase(); } } //插入数据的方法 classInsertListenerimplementsOnClickListener{ @Override publicvoidonClick(Viewv){ StuDBHelperdbHelper=newStuDBHelper(SQLiteActivity.this,"stu_db",null,1); //得到一个可写的数据库 SQLiteDatabasedb=dbHelper.getWritableDatabase(); //生成ContentValues对象//key:列名,value:想插入的值 ContentValuescv=newContentValues(); //往ContentValues对象存放数据,键-值对模式 cv.put("id",1); cv.put("sname","xiaoming"); cv.put("sage",21); cv.put("ssex","male"); //调用insert方法,将数据插入数据库 db.insert("stu_table",null,cv); //关闭数据库 db.close(); } } //查询数据的方法 classQueryListenerimplementsOnClickListener{ @Override publicvoidonClick(Viewv){ StuDBHelperdbHelper=newStuDBHelper(SQLiteActivity.this,"stu_db",null,1); //得到一个可写的数据库 SQLiteDatabasedb=dbHelper.getReadableDatabase(); //参数1:表名 //参数2:要想显示的列 //参数3:where子句 //参数4:where子句对应的条件值 //参数5:分组方式 //参数6:having条件 //参数7:排序方式 Cursorcursor=db.query("stu_table",newString[]{"id","sname","sage","ssex"},"id=?",newString[]{"1"},null,null,null); while(cursor.moveToNext()){ Stringname=cursor.getString(cursor.getColumnIndex("sname")); Stringage=cursor.getString(cursor.getColumnIndex("sage")); Stringsex=cursor.getString(cursor.getColumnIndex("ssex")); System.out.println("query------->"+"姓名:"+name+""+"年龄:"+age+""+"性别:"+sex); } //关闭数据库 db.close(); } } //修改数据的方法 classModifyListenerimplementsOnClickListener{ @Override publicvoidonClick(Viewv){ StuDBHelperdbHelper=newStuDBHelper(SQLiteActivity.this,"stu_db",null,1); //得到一个可写的数据库 SQLiteDatabasedb=dbHelper.getWritableDatabase(); ContentValuescv=newContentValues(); cv.put("sage","23"); //where子句"?"是占位符号,对应后面的"1", StringwhereClause="id=?"; String[]whereArgs={String.valueOf(1)}; //参数1是要更新的表名 //参数2是一个ContentValeus对象 //参数3是where子句 db.update("stu_table",cv,whereClause,whereArgs); } } //删除数据的方法 classDeleteListenerimplementsOnClickListener{ @Override publicvoidonClick(Viewv){ StuDBHelperdbHelper=newStuDBHelper(SQLiteActivity.this,"stu_db",null,1); //得到一个可写的数据库 SQLiteDatabasedb=dbHelper.getReadableDatabase(); StringwhereClauses="id=?"; String[]whereArgs={String.valueOf(2)}; //调用delete方法,删除数据 db.delete("stu_table",whereClauses,whereArgs); } } } StuDBHelper.java packagecom.lingdududu.testSQLiteDb; importandroid.content.Context; importandroid.database.sqlite.SQLiteDatabase; importandroid.database.sqlite.SQLiteDatabase.CursorFactory; importandroid.database.sqlite.SQLiteOpenHelper; importandroid.util.Log; publicclassStuDBHelperextendsSQLiteOpenHelper{ privatestaticfinalStringTAG="TestSQLite"; publicstaticfinalintVERSION=1; //必须要有构造函数 publicStuDBHelper(Contextcontext,Stringname,CursorFactoryfactory, intversion){ super(context,name,factory,version); } //当第一次创建数据库的时候,调用该方法 publicvoidonCreate(SQLiteDatabasedb){ Stringsql="createtablestu_table(idint,snamevarchar(20),sageint,ssexvarchar(10))"; //输出创建数据库的日志信息 Log.i(TAG,"createDatabase------------->"); //execSQL函数用于执行SQL语句 db.execSQL(sql); } //当更新数据库的时候执行该方法 publicvoidonUpgrade(SQLiteDatabasedb,intoldVersion,intnewVersion){ //输出更新数据库的日志信息 Log.i(TAG,"updateDatabase------------->"); } } main.xml <?xmlversion="1.0"encoding="utf-8"?> <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <Button android:id="@+id/createDatabase" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="创建数据库" /> <Button android:id="@+id/updateDatabase" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="更新数据库" /> <Button android:id="@+id/insert" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="插入数据" /> <Button android:id="@+id/update" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="更新数据" /> <Button android:id="@+id/query" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="查询数据" /> <Button android:id="@+id/delete" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="删除数据" /> </LinearLayout> 程序运行的效果图: 当点击创建数据库按钮: LogCat窗口输出的信息为: 当点击更新数据库按钮: LogCat窗口输出的信息为: 当点击查询数据库按钮: LogCat窗口输出的信息为: 使用adb命令查看数据库: 1.在命令行窗口输入adb shell回车,就进入了Linux命令行,现在就可以使用Linux的命令了。 2.ls回车,显示所有的东西,其中有个data。(ls:显示所有,cd:进入) 3.cd data回车,再ls回车,cd data回车,ls回车后就会看到很多的com.。。。,那就是系统上的应用程序包名,找到你数据库程序的包名,然后进入。 4.进去后在查看所有,会看到有databases,进入databases,显示所有就会发现你的数据库名字,这里使用的是"stu_db"。 5.sqlite3 stu_db回车就进入了你的数据库了,然后“.schema”就会看到该应用程序的所有表及建表语句。 6.之后就可以使用标准的SQL语句查看刚才生成的数据库及对数据执行增删改查了。 #sqlite3 stu_dbsqlite3 stu_dbSQLite version 3.6.22 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite>.schema.schema CREATE TABLE android_metadata (locale TEXT); CREATE TABLEstu_table(id int,sname varchar(20),sage int,ssex varchar(10));--->创建的表 sqlite>select * from stu_table; select * from stu_table; 1|xiaoming|21|male sqlite> 插入数据 sqlite>insert into stu_table values(2,'xiaohong',20,'female'); 插入的数据记得要和表中的属性一一对应 insert into stu_table values(2,'xiaohong',20,'female'); sqlite> select * from stu_table; select * from stu_table; 1|xiaoming|21|male 2|xiaohong|20|female--------------> 插入的数据sqlite> 当点击修改数据的按钮时候 sqlite> select * from stu_table; select * from stu_table; 1|xiaoming|23|male-------------->年龄被修改为232|xiaohong|20|female sqlite> 当点击删除数据的按钮 sqlite> select * from stu_table; select * from stu_table; 1|xiaoming|23|maleid=2的数据已经被删除 总之,我们可以在代码中执行数据库的增删改查,也可以在adb命令行下实现。不过因为SQLite没有客户端,不能直接的查看数据库变化后的信息,所以常用adb命令行查看数据库改变后的信息。 本文转自 lingdududu 51CTO博客,原文链接: http://blog.51cto.com/liangruijun/663686

优秀的个人博客,低调大师

Android开发学习笔记:BroadcastReceiver简介和注册方式

一.BroadcastReceiver简介 BraodcastReceiver(广播接收器)是为了实现系统广播而提供的一种组件,它和事件处理机制类似,但是事件处理机制是程序组件级别的,而广播事件处理机制是系统级别的。比如,我们可以发出一种广播来测试手机电量的变化,这时候就可以定义一个BraodcastReceiver来接受广播,当手机电量较低时提示用户。我们既可以用Intent来启动一个组件,也可以用sendBroadcast()方法发起一个系统级别的事件广播来传递消息。我们同样可以在自己的应用程序中实现BroadcastReceiver来监听和响应广播的Intent。 在程序中使用BraodcastReceiver是比较简单的。首先要定义一个类继承BraodcastReceiver,并且覆盖onReceiver()方法来响应事件。然后注册在程序中BraodcastReceiver。最后构建Intent对象调用sendBroadcast()方法将广播发出。 二.BroadcastReceiver的注册方式 1.静态注册方式 静态注册方式是在AndroidManifest.xml的application里面定义receiver并设置要接收的action。静态注册方式的特点:不管改应用程序是否处于活动状态,都会进行监听,比如某个程序时监听 下面是具体的例子: MainActivity.java packagecom.android.broadcast; importandroid.app.Activity; importandroid.content.Intent; importandroid.os.Bundle; importandroid.view.View; importandroid.view.View.OnClickListener; importandroid.widget.Button; publicclassMainActivityextendsActivity{ //定义action常量 protectedstaticfinalStringACTION="com.android.broadcast.RECEIVER_ACTION"; //定义Button对象 privateButtonbtnBroadcast; @Override publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); btnBroadcast=(Button)findViewById(R.id.btnBroadcast); //为按钮设置单击监听器 btnBroadcast.setOnClickListener(newOnClickListener(){ @Override publicvoidonClick(Viewv){ //实例化Intent Intentintent=newIntent(); //设置Intent的action属性 intent.setAction(ACTION); //发出广播 sendBroadcast(intent); } }); } } 在“com.android.broadcast”包中定义一个MyReceiver类,继承于BroadcastReceiver,覆盖onReceive()方法。 MyReceiver.java packagecom.android.broadcast; importandroid.content.BroadcastReceiver; importandroid.content.Context; importandroid.content.Intent; importandroid.util.Log; publicclassMyReceiverextendsBroadcastReceiver{ //定义日志标签 privatestaticfinalStringTAG="Test"; @Override publicvoidonReceive(Contextcontext,Intentintent){ //输出日志信息 Log.i(TAG,"MyReceiveronReceive--->"); } } main.xml <?xmlversion="1.0"encoding="utf-8"?> <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Button android:id="@+id/btnBroadcast" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="发送Broadcast" /> </LinearLayout> 在AndroidManifest.xml配置文件中16~20行声明receiver <?xmlversion="1.0"encoding="utf-8"?> <manifestxmlns:android="http://schemas.android.com/apk/res/android" package="com.android.broadcast" android:versionCode="1" android:versionName="1.0"> <uses-sdkandroid:minSdkVersion="10"/> <applicationandroid:icon="@drawable/icon"android:label="@string/app_name"> <activityandroid:name=".MainActivity" android:label="@string/app_name"> <intent-filter> <actionandroid:name="android.intent.action.MAIN"/> <categoryandroid:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <receiverandroid:name="MyReceiver"> <intent-filter> <actionandroid:name="com.android.broadcast.RECEIVER_ACTION"/> </intent-filter> </receiver> </application> </manifest> 效果图: 当我们点击按钮的时候,程序会调用onReceive()方法,LogCat输出信息如下: 2.动态注册方式 动态注册方式在activity里面调用函数来注册,和静态的内容差不多。一个形参是receiver,另一个是IntentFilter,其中里面是要接收的action。动态注册方式特点:在代码中进行注册后,当应用程序关闭后,就不再进行监听。 下面是具体的例子: MainActivity.java packagecom.android.broadcast; importandroid.app.Activity; importandroid.content.Intent; importandroid.content.IntentFilter; importandroid.os.Bundle; importandroid.view.View; importandroid.view.View.OnClickListener; importandroid.widget.Button; publicclassMainActivityextendsActivity{ //定义Action常量 protectedstaticfinalStringACTION="com.android.broadcast.RECEIVER_ACTION"; privateButtonbtnBroadcast; privateButtonregisterReceiver; privateButtonunregisterReceiver; privateMyReceiverreceiver; @Override publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); btnBroadcast=(Button)findViewById(R.id.btnBroadcast); //创建事件监听器 btnBroadcast.setOnClickListener(newOnClickListener(){ @Override publicvoidonClick(Viewv){ Intentintent=newIntent(); intent.setAction(ACTION); sendBroadcast(intent); } }); registerReceiver=(Button)findViewById(R.id.btnregisterReceiver); //创建事件监听器 registerReceiver.setOnClickListener(newOnClickListener(){ @Override publicvoidonClick(Viewv){ receiver=newMyReceiver(); IntentFilterfilter=newIntentFilter(); filter.addAction(ACTION); //动态注册BroadcastReceiver registerReceiver(receiver,filter); } }); unregisterReceiver=(Button)findViewById(R.id.btnunregisterReceiver); //创建事件监听器 unregisterReceiver.setOnClickListener(newOnClickListener(){ @Override publicvoidonClick(Viewv){ //注销BroadcastReceiver unregisterReceiver(receiver); } }); } } 在“com.android.broadcast”包中定义一个MyReceiver类,继承于BroadcastReceiver,覆盖onReceive()方法。 MyReceiver.java packagecom.android.broadcast; importandroid.content.BroadcastReceiver; importandroid.content.Context; importandroid.content.Intent; importandroid.util.Log; publicclassMyReceiverextendsBroadcastReceiver{ //定义日志标签 privatestaticfinalStringTAG="Test"; @Override publicvoidonReceive(Contextcontext,Intentintent){ //输出日志信息 Log.i(TAG,"MyReceiveronReceive--->"); } } main.xml <?xmlversion="1.0"encoding="utf-8"?> <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Button android:id="@+id/btnBroadcast" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="发送广播" /> <Button android:id="@+id/btnregisterReceiver" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="注册广播接收器" /> <Button android:id="@+id/btnunregisterReceiver" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="注销广播接听器" /> </LinearLayout> 效果图: ①当我们首先点击按钮的时候,因为程序没有注册BraodcastReceiver,所以LogCat没有输出任何信息。 ②当我们先点击再点击按钮的时候,这时程序会动态的注册BraodcastReceiver,之后会调用onReceive()方法,LogCat输出信息如下: ③当我们点击按钮的时候,这时程序会注销BraodcastReceiver,再点击,LogCat没有输出任何信息。 三.BroadcastReceiver的生命周期 一个BroadcastReceiver 对象只有在被调用onReceive(Context, Intent)的才有效的,当从该函数返回后,该对象就无效的了,结束生命周期。 本文转自 lingdududu 51CTO博客,原文链接:http://blog.51cto.com/liangruijun/655885

优秀的个人博客,低调大师

Android开发学习笔记:浅谈Tab选项卡

Tab选项卡是一个非常方便的组件。 一.使用Tab组件的步骤: 1.在布局文件中使用FrameLayout列出Tab组件以及Tab中的内容组件 2.Activity要继承TabActivity 3.调用TabActivity的getTabHost( )方法来获得TabHost对象 4.通过TabHost创建Tab选项 二.实现不同Tab里面的内容有两种方式: 1.切换不同的Tab时候,不同Tab里面的内容在同一个Activity显示,主要是通过修改布局文件里面的id来实现的。下面是一个具体的例子: MainActivity.java packagecom.android.tab.activity; importandroid.app.TabActivity; importandroid.os.Bundle; importandroid.view.LayoutInflater; importandroid.widget.TabHost; publicclassMainActivityextendsTabActivity{ @Override publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); //获得TabHost对象 TabHosttah=getTabHost(); //from(this)从TabActivity获取LayoutInflater //R.layout.main存放Tab布局 //通过TabHost获得存放Tab标签页内容的FrameLayout //是否将inflate加到根布局元素上 LayoutInflater.from(this).inflate(R.layout.main,tah.getTabContentView(),true); //设置Tab标签的内容和显示内容 tah.addTab(tah.newTabSpec("tab1").setIndicator("图片1").setContent(R.id.TextView01)); tah.addTab(tah.newTabSpec("tab2").setIndicator("图片2").setContent(R.id.TextView02)); tah.addTab(tah.newTabSpec("tab3").setIndicator("图片3").setContent(R.id.TextView03)); } } main.xml <?xmlversion="1.0"encoding="utf-8"?> <FrameLayoutxmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/FrameLayout01" android:layout_width="wrap_content" android:layout_height="wrap_content" > <TabHost android:id="@+id/TabHost01" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/TextView01" android:background="@drawable/pic1" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/TextView02" android:background="@drawable/pic2" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/TextView03" android:background="@drawable/pic3" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </FrameLayout> 效果图: 1.切换不同的Tab时候,不同Tab里面的内容在不同的Activity显示 先创建三个类FirstActivity.java,SecondActivity.java,ThirdActivity.java,都是继承Activity FirstActivity.java packagecom.android.tabtest.activity; importandroid.app.Activity; importandroid.os.Bundle; importandroid.widget.TextView; publicclassFirstActivityextendsActivity{ publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); TextViewtextview=newTextView(this); textview.setText("这是Tab1"); setContentView(textview); } } SecondActivity.java packagecom.android.tabtest.activity; importandroid.app.Activity; importandroid.os.Bundle; importandroid.widget.TextView; publicclassSecondActivityextendsActivity{ publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); TextViewtextview=newTextView(this); textview.setText("这是Tab2"); setContentView(textview); } } ThirdActivity.java packagecom.android.tabtest.activity; importandroid.app.Activity; importandroid.os.Bundle; importandroid.widget.TextView; publicclassThirdActivityextendsActivity{ publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); TextViewtextview=newTextView(this); textview.setText("这是Tab3"); setContentView(textview); } } 在layout文件夹中对main.xml进行修改 <?xmlversion="1.0"encoding="utf-8"?> <TabHostandroid:id="@android:id/tabhost"android:layout_width="fill_parent" android:layout_height="fill_parent"xmlns:android="http://schemas.android.com/apk/res/android"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp" /> </LinearLayout> </TabHost> 新建一个测试Tab的类TabDemo.java,继承于TabActivity类 packagecom.android.tabtest.activity; importandroid.app.TabActivity; importandroid.content.Intent; importandroid.content.res.Resources; importandroid.os.Bundle; importandroid.widget.TabHost; importandroid.widget.TabHost.TabSpec; publicclassTabDemoextendsTabActivity{ /**Calledwhentheactivityisfirstcreated.*/ @Override publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main);//这里使用了上面创建的xml文件(Tab页面的布局) Resourcesres=getResources();//ResourceobjecttogetDrawables TabHosttabHost=getTabHost();//TheactivityTabHost TabSpecspec; Intentintent;//ReusableIntentforeachtab //第一个Tab intent=newIntent(this,FirstActivity.class);//新建一个Intent用作Tab1显示的内容 spec=tabHost.newTabSpec("tab1")//新建一个Tab .setIndicator("Tab1",res.getDrawable(android.R.drawable.ic_media_play))//设置名称以及图标 .setContent(intent);//设置显示的intent,这里的参数也可以是R.id.xxx tabHost.addTab(spec);//添加进tabHost //第二个Tab intent=newIntent(this,SecondActivity.class);//第二个Intent用作Tab1显示的内容 spec=tabHost.newTabSpec("tab2")//新建一个Tab .setIndicator("Tab2",res.getDrawable(android.R.drawable.ic_menu_edit))//设置名称以及图标 .setContent(intent);//设置显示的intent,这里的参数也可以是R.id.xxx tabHost.addTab(spec);//添加进tabHost //第三个Tab intent=newIntent(this,SecondActivity.class);//第二个Intent用作Tab1显示的内容 spec=tabHost.newTabSpec("tab2")//新建一个Tab .setIndicator("Tab3",res.getDrawable(android.R.drawable.ic_menu_help))//设置名称以及图标 .setContent(intent);//设置显示的intent,这里的参数也可以是R.id.xxx tabHost.addTab(spec);//添加进tabHost tabHost.setCurrentTab(0);//设置当前的选项卡,这里为Tab1 } } 在AndroidManifest.xml里加入9~29行的声明代码 <?xmlversion="1.0"encoding="utf-8"?> <manifestxmlns:android="http://schemas.android.com/apk/res/android" package="com.android.tabtest.activity" android:versionCode="1" android:versionName="1.0"> <uses-sdkandroid:minSdkVersion="10"/> <applicationandroid:icon="@drawable/icon"android:label="@string/app_name"> <activityandroid:name=".TabDemo" android:label="@string/app_name"> <intent-filter> <actionandroid:name="android.intent.action.MAIN"/> <categoryandroid:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activityandroid:name=".FirstActivity" android:label="@string/app_name"> <intent-filter> <actionandroid:name="android.intent.action.MAIN"/> <categoryandroid:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activityandroid:name=".SecondActivity" android:label="@string/app_name"> <intent-filter> <actionandroid:name="android.intent.action.MAIN"/> <categoryandroid:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> </application> </manifest> 效果图: 本文转自 lingdududu 51CTO博客,原文链接: http://blog.51cto.com/liangruijun/643043

优秀的个人博客,低调大师

Android开发者指南(29) —— USB Host and Accessory

USB主从设备 Android支持各种USB外围设备,通过两种模式来支持Android USB外设(实现了Android外设协议的硬件):USB外设模式和USB主机模式。在USB外设模式下,外部USB硬件(装有Android的设备要连接的外部设备)充当USB主机。外设的例子包括机器人、扩展插座、诊断和音乐设备、电子报亭、读卡器等其他设备。这种模式给予不具备主机功能的Android设备以与USB硬件交互的能力。Android USB外设必须设计用来与装有Android的设备一起工作,并且必须遵循Android外设通讯协议。在USB主机模式下,装有Android的设备扮演着主机的角色。这种设备的例子包括数码像机,键盘,鼠标和游戏手柄。那些适应面很广的USB设备仍可以与Android应用交互,前提是这些Android应用可以正确的与这些设备通讯。 图1展示了两种模式的异同。当Android设备处于主机模式时,它扮演USB主机角色并为总线供电。当Android设备处于附件模式时,被连接的USB硬件(在这种情况下是一个Android USB附件)扮演主机角色并给总线供电。 图1. USB主从模式 USB外设和主机模式在Android 3.1 (API level 12)或更高的平台中直接支持。USB外设模式作为一个外设库也被回馈到Android 2.3.4 (API level 10)来支持更广泛的设备。设备厂商可以选择是否在设备的系统镜像中包含附加库。 注意:对USB主机和外设模式的支持最终取决于设备的硬件,不管平台的等级(是多少)。你可以通过<uses-feature>元素过滤那些支持USB主机和外设的设备。查看USB外设和主机文档获取更多详细信息。 调试注意事项 当调试那些使用了USB外设和主机特性的应用时,你很有可能把你的USB硬件连接到你的Android设备上,这将阻止你通过USB建立adb到Android设备的连接。你通过网络仍可以访问adb。通过网络连接adb: 通过USB将Android设备连接到电脑。 从SDK的platform-tools目录,在命令行输入adb tcpip 5555 输入:adb connect <设备的IP地址>:5555,你现在将被连接到Android设备并能像adb logcat一样发出通用的adb命令。 要设置你的设备监听USB,输入adb usb。 本文转自over140 51CTO博客,原文链接:http://blog.51cto.com/over140/716803,如需转载请自行联系原作者

优秀的个人博客,低调大师

Android开发10——Activity的跳转与传值

Activity跳转与传值,主要是通过Intent类,Intent的作用是激活组件和附带数据。 intent可以激活Activity,服务,广播三类组件。本博文讲的是显示意图激活Activity组件。所谓显示意图就是在activity的激活时,显示指出了需要激活的activity的名字。 一、Activity跳转 方法一 Intent intent = new Intent(A.this, B.class); startActivity(intent); 方法二 Intent intent = new Intent(); intent.setClass(A.this, B.class); startActivity(intent); 实现从A跳转到B(A、B均继承自Activity) 二、传递数据 Activity A 传递数据 方法一 Intent intent = new Intent(); intent.setClass(A.this, B.class); intent.putExtra("name", "xy"); intent.putExtra("age", 22); startActivity(intent); 方法二 Intent intent = new Intent(A.this, B.class); Bundle bundle = new Bundle(); bundle.putString("name", "xy"); bundle.putInt("age", 22); intent.putExtras(bundle); startActivity(intent); Activity B 接收数据 // 获取参数1 Intent intent = this.getIntent(); String name = intent.getStringExtra("name"); int age = intent.getIntExtra("age", 22);// 缺省值为22 // 获取参数2 Bundle bundle = intent.getExtras(); String name2 = bundle.getString("name"); int age2 = bundle.getInt("age", 22); 两种获取参数方式均可,并不是和传参1,2方法一一对应 三、Activity返回值 跳转后前一个Activity已经被destroy了。如若要返回并显示数据,就必须将前一个Activity再次唤醒,同时调用某个方法来获取并显示数据。做法如下 1.从A页面跳转到B页面时不可使用startActivity()方法,而要使用startActivityForResult()方法 2.在A页面的Activity中,需要重写onActivityResult(int requestCode, int resultCode, Intent data)方法 Activity A //有返回值的Activity publicvoidopenNewActivity2(Viewv) { Intentintent=newIntent(); intent.setClass(this.getApplicationContext(),OtherActivity2.class); intent.putExtra("name","xy"); intent.putExtra("age",20); startActivityForResult(intent,1); } @Override protectedvoidonActivityResult(intrequestCode,intresultCode,Intentdata) { //requestCode用于区分业务 //resultCode用于区分某种业务的执行情况 if(1==requestCode&&RESULT_OK==resultCode) { Stringresult=data.getStringExtra("result"); Toast.makeText(this.getBaseContext(),result,Toast.LENGTH_SHORT).show(); } else { Toast.makeText(this.getBaseContext(),"无返回值",Toast.LENGTH_SHORT).show(); } } Activity B publicvoidclose(Viewv) { Intentintent=newIntent(); intent.putExtra("result","返回值"); this.setResult(RESULT_OK,intent);//设置结果数据 this.finish();//关闭Activity } 四、总结 以上采用的意图intent均是显示意图。 参考地址:http://www.cnblogs.com/feng88724/archive/2011/02/10/1961225.html 本文转自IT徐胖子的专栏博客51CTO博客,原文链接http://blog.51cto.com/woshixy/1081317如需转载请自行联系原作者 woshixuye111

优秀的个人博客,低调大师

Android开发7——android.database.CursorIndexOutOfBoundsException:Index -1 ...

android中数据库处理使用cursor时,游标不是放在为0的下标,而是放在为-1的下标处开始的。 也就是说返回给cursor查询结果时,不能够马上从cursor中提取值。 下面的代码会返回错误 Useru=null; SQLiteDatabasedb=dbHelper.getReadableDatabase(); Cursorcursor=db.rawQuery("select*fromuserwhereid=?",newString[]{id.toString()}); Integeruid=cursor.getInt(cursor.getColumnIndex("id")); Stringuname=cursor.getString(cursor.getColumnIndex("name")); floatuamount=cursor.getFloat(cursor.getColumnIndex("amount")); u=newUser(uid,uname,uamount); 正确的用法 Useru=null; SQLiteDatabasedb=dbHelper.getReadableDatabase(); Cursorcursor=db.rawQuery("select*fromuserwhereid=?",newString[]{id.toString()}); if(cursor.moveToFirst()) { Integeruid=cursor.getInt(cursor.getColumnIndex("id")); Stringuname=cursor.getString(cursor.getColumnIndex("name")); floatuamount=cursor.getFloat(cursor.getColumnIndex("amount")); u=newUser(uid,uname,uamount); } 本文转自IT徐胖子的专栏博客51CTO博客,原文链接http://blog.51cto.com/woshixy/1079514如需转载请自行联系原作者 woshixuye111

优秀的个人博客,低调大师

Android开发学习笔记:数据存取之Preference浅析

一.Preference的简介 Preference(配置)提供了一种轻量级的数据存取方法,主要应用于数据比较少的配置信息。它以“key-value”(是一个Map)对的方式将数据保存在一个XML配置文件中,例如,手机的开机问候语,可以将其以Preference方式来进行配置。也可以保存一些用户个性化设置的字体、颜色、位置等参数信息。 二.Preference存取数据的方法 使用到的接口: SharedPreferences接口和SharedPreferences.Editor接口,它们都是来自于andorid.content包。 ①SharedPreferences接口提供保存数据的方法 我们可以调用Context.getSharedPreferences(String name,int mode)方法得到SharedPreferences接口。该方法的第一个参数是文件名称,第二个参数是操作模式。操作模式有三种: MODE_PRIVATE(私有) MODE_WORLD_READABLE(可读) MODE_WORLD_WRITEABLE(可写) SharedPreferences接口的常用方法 方法名称 方法描述 edit() 返回SharedPreferences的内部接口SharedPreferences.Editor contains(String key) 判断是否包含该键值 getAll() 返回所有配置信息Map getBoolean(String key,Boolean defValue) 获得一个boolean值 getFloat(String key,float defValue) 获得一个float值 getInt(String key,int defValue) 获得一个int值 getLong(String key,long defValue) 获得一个long值 getString(String key,String defValue) 获得一个String值 ②SharedPreferences.Editor接口提供获得数据的方法 SharedPreferences.Editor接口中的getString(String key,String defValue)、getInt(String key,int defValue)等。调用SharedPreferences的edit()方法返回SharedPreferences.Editor内部接口,该接口中提供了保存数据的方法,如putString(String key,String value)、pubInt(String key,int value)等,调用该接口的commit方法可以将数据进行保存。 SharedPreferences.Editor接口常用的方法 方法名称 方法描述 clear() 清楚所有值 commit() 保存 getAll() 返回所有配置信息Map putBoolean(String key,Boolean value) 保存一个boolean值 putFloat(String key,float value) 保存一个float值 putInt(String key,int value) 保存一个int值 putLong(String key,long value) 保存一个long值 putString(String key,String value) 保存一个String值 remove(String key) 删除该键对应的键 下面是保存临时记事本内容的例子 当我们在手机上用记事本编写备忘录,日志的时候,突然要返回接电话,看短信的时候。我们就要停止编写,退出去听接电话,看短信。然而,当我们打完电话或者看完短信回来的时候,发现刚刚编写的内容还在记事本上,这就是Preference的作用了。 创建一个Activity,在其中放置一个EditText保存短信内容,放置一个Button用于发送信息。在onCreate()中通过getSharedPreferences()方法获得SharedPreferences接口,调用接口的getString()方法,获得保存内容,将内容设置到EditText中。 在onStop()方法中保存内容,使用getSharedPreferences().edit()方法获得SharedPreferences.Editor接口,调用SharedPreferences.Editor的putString()方法保存短信内容,调用commit()方法提交内容。 MainActivity.java packagecom.android.preference; importandroid.app.Activity; importandroid.content.SharedPreferences; importandroid.os.Bundle; importandroid.widget.Button; importandroid.widget.EditText; publicclassMainActivityextendsActivity{ privateEditTextmyEditText; privateButtonbtn; privatestaticfinalStringTEMP_INFO="temp_info"; @Override publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); myEditText=(EditText)findViewById(R.id.EditText1); btn=(Button)findViewById(R.id.Button1); //获得SharedPreferences实例 SharedPreferencessp=getSharedPreferences(TEMP_INFO,MODE_WORLD_READABLE); //从SharedPreferences获得备忘录的内容 Stringcontent=sp.getString("info_content",""); //在EditText中显示备忘录内容 myEditText.setText(content); } @Override protectedvoidonStop(){ super.onStop(); //获得编辑器 SharedPreferences.Editoreditor=getSharedPreferences(TEMP_INFO,MODE_WORLD_WRITEABLE).edit(); //将EditText中的文本内容添加到编辑器 editor.putString("info_content",myEditText.getText().toString()); //提交编辑器内容 editor.commit(); } } main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="备忘录" /> <EditText android:text="" android:id="@+id/EditText1" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <Button android:id="@+id/Button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="保存" /> </LinearLayout> 效果图: 当我们退出屏幕再返回的时候,发现原来备忘录里编辑了一半的内容还在那里,其实它是把要保存的内容做诶XML文件保存在/data/data/package/shsared_prefs/下面了。 本文转自 lingdududu 51CTO博客,原文链接:http://blog.51cto.com/liangruijun/658521

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册