<span id="Label3"></p><p><p>Since the development of the application needs to build servers and databases, so understand the online back-end cloud services, The initial understanding of the choice of domestic bmob, the following is a brief introduction of its use:</p></p>1. Register BMOB Account<p><p>Enter www.bmob.cn in the URL field or in the Baidu input Bmob to search, open Bmob official website, Click on the top right corner of the "registration", in the jump page fill in your name, email, set the password, confirm to your mailbox activation Bmob account, You can use Bmob easy to develop the Application.</p></p><p><p></p></p>2. Site background Creation app<p><p>After entering the Bmob backstage, click "create app" in the upper left corner of the background screen, enter the name of your app in the pop-up box, then confirm that you have an app waiting to be Developed.</p></p><p><p></p></p>3. Get the app key and download the SDK<p><p>Select the app you want to develop and go to the app</p></p><p><p></p></p><p><p>On the jump page, go to settings/app key, click Copy to get Application ID</p></p><p><p></p></p><p><p></p></p><p><p></p></p>4. Installing BMOBSDK<p><p>first, Create the "libs" directory under your project root directory and place the downloaded BMOBSDK file in the Directory.</p></p><p><p>second, Add the appropriate permissions in your Application's <code>AndroidManifest.xml</code> files:</p></p><pre class="brush:php;gutter:true;"><uses-permission android:name= "android.permission.INTERNET"/><uses-permission android:name= " Android.permission.ACCESS_WIFI_STATE "/><uses-permission android:name=" android.permission.ACCESS_NETWORK_ State "/><uses-permission android:name=" Android.permission.READ_PHONE_STATE "/><uses-permission Android:name= "android.permission.WRITE_EXTERNAL_STORAGE"/><uses-permission android:name= " Android.permission.READ_LOGS "/><?xml version=" 1.0 "encoding=" utf-8 "?> <manifest xmlns:android="/http/ Schemas.android.com/apk/res/android "package=" cn.bmob.example "android:versioncode=" 1 "android:versio Nname= "1.0" > <uses-sdk android:minsdkversion= "8" android:targetsdkversion= "+"/> <uses-permission Andro Id:name= "android.permission.INTERNET"/> <uses-permission android:name= "android.permission.ACCESS_NETWORK_ State "/> <uses-permission android:name=" Android.permission.ACCESS_WIFI_STATE "/> <uses-permission Android:name= "android.permission.READ_PHONE_STATE"/> <uses-permission android:name= " Android.permission.RECEIVE_BOOT_COMPLETED "/> <uses-permission android:name=" android.permission.WRITE_ External_storage "/> <uses-permission android:name=" Android.permission.READ_LOGS "/> <application A ndroid:allowbackup= "true" android:icon= "@drawable/ic_launcher" android:label= "@string/app_name" Andro Id:theme= "@style/apptheme" > <activity android:name= "cn.bmob.example.MainActivity" andro id:screenorientation= "portrait" android:label= "@string/app_name" > <action android:name= "an Droid.intent.action.MAIN "/> <category android:name=" Android.intent.category.LAUNCHER "/> < ; Activity android:name= ". Createactivity "android:screenorientation=" portrait "> <activity android:name=". Deleteactivity "android:screenorientation= "portrait" > <activity android:name= ". Updateactivity "android:screenorientation=" portrait "> <activity android:name=". Findactivity "android:screenorientation=" Portrait "> </application></manifest></pre><p><p> </p></p>Initialize BMOBSDK<p><p>Initialize the Bmob feature in the OnCreate () method of the activity that your application Launches. The code looks like This:</p></p><pre class="brush:java;gutter:true;"><pre class="brush:java;gutter:true;">Package Com.bmob.example;import Cn.bmob.v3.bmob;import Android.app.activity;import Android.os.bundle;public class Mainactivity extends Activity { @Override protected void onCreate (Bundle Savedinstancestate) { //TODO auto-generated method Stub super.oncreate (savedinstancestate); When initializing the Bmob SDK //use, replace the second parameter application ID with the application ID you created on the Bmob server (this, bmob.initialize Application ID ");} }</pre></pre><p><p> </p></p>Add a row of data<p><p>First create the JavaBean (corresponding to the bmob background data table, More detailed explanation please see the Android development Documentation)</p></p><pre class="brush:java;gutter:true;"><pre class="brush:java;gutter:true;">public class person extends Bmobobject { private String name; Private String address; Public String getName () { return name; } public void SetName (String name) { this.name = name; } Public String getaddress () { return address; } public void setaddress (String address) { this.address = address; }}</pre></pre><p><p> </p></p><p><p>Add data</p></p><pre class="brush:java;gutter:true;"><pre class="brush:java;gutter:true;">person P2 = new person ();p 2.setName ("lucky");p 2.setAddress ("beijing haidian");p 2.save (this, new Savelistener () { @Override c15/>public void onsuccess () { //TODO auto-generated method stub Toast ("add data successfully, return Objectid to:" + P2.getobjectid ()); } @Override public void onfailure (int code, String msg) { //TODO auto-generated method stub Toast ("failed to create Data: "+ msg);} });</pre></pre><p><p> </p></p><p><p>If the toast is added to the data success message, you will see a row of new data in the BMOB corresponding application ID data table, as shown in:</p></p><p><p></p></p>Get a row of data<pre class="brush:java;gutter:true;"><pre class="brush:java;gutter:true;">Look for data with ID 6b6c11c537 inside the person table bmobquery<person> bmobquery = new bmobquery<person> (); bmobquery.getobject (this, "6b6c11c537", New getlistener<person> () { @Override public void onsuccess (person Object) { // TODO auto-generated Method Stub Toast ("query succeeded"); } @Override public void onfailure (int code, String msg) { //TODO auto-generated method stub Toast ("query failed:" + msg ); }});</pre></pre><p><p> </p></p>Modify a row of data<pre class="brush:java;gutter:true;"><pre class="brush:java;gutter:true;">Update the person table with ID 6b6c11c537 data, address content updated to "beijing chaoyang" person p2 = new person ();p 2.setAddress ("beijing chaoyang");p 2.update (this, " 6b6c11c537 ", New Updatelistener () { @Override public void onsuccess () { //TODO auto-generated method stub< C3/>toast ("update succeeded:" + p2.getupdatedat ()); } @Override public void onfailure (int code, String msg) { //TODO auto-generated method stub Toast ("update failed:" + msg ); }});</pre></pre><p><p> </p></p>Delete a row of data<pre class="brush:java;gutter:true;"><pre class="brush:java;gutter:true;">person P2 = new person ();p 2.setObjectId ("6b6c11c537");p 2.delete (this, new Deletelistener () { @Override public void onsuccess () { //TODO auto-generated method stub Toast ("delete succeeded"); } @Override public void onfailure (int code, String msg) { //TODO auto-generated method stub Toast ("delete failed:" + (msg); }});</pre></pre><p><p>--------------------------</p></p><p><p>The above is the basic use of the Back-end cloud, more features need to be further practiced.</p></p><p><p>Android Development Backend Cloud Bmob usage</p></p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service