In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how to get started with Ophone and Android. I think it's very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it.
The following is the introduction to OPhone/Androind summarized by JavaEye's zhang_xzhi_xjtu. The editor feels good and is recommended for you to learn. Because OPhone is essentially no different from Android, although OPhone is used in this tutorial, it is essentially an introduction to Android.
Mainly, for some readers, the tutorial has two small shortcomings: 1 is traditional characters, and 2 is that the author takes care of many beginner programmers and writes in too much detail, such as taking time to talk about some grammar of java,xml.
The characteristic is, 1 Putonghua, 2 for programmers with java,xml experience. Mainly from a small example to illustrate some of the important concepts of OPhone/Android.
The goal is to get a 5-minute quick start in addition to building the environment. And provide a simple program code can be used to modify and verify some OPhone/Android entry ideas, and have a general understanding of the important concepts of OPhone/Android. The test environment for code provided is OPhone.
1 background
What is Android?
Android is an open source mobile operating system based on Linux platform developed by Google.
What is OPhone?
OPhone is a customized mobile phone under China Mobile's OMS system. The programs on OPhone are compatible with Android.
What is Emulator?
It is convenient for programmers to develop programs on other devices, while a software simulator is made for other devices. The developed program can be deployed, executed and debugged on the simulator.
2 install the development environment
Android: http://code.google.com/p/androidbmi/wiki/InstallAndroid
JDK5+
Eclipse3.3+
ADT
Android SDK (including Emulator)
OPhone: http://www.ophonesdn.com/documentation/ophone/gettingstarted/installing_sdk.html
JDK5+
Eclipse3.4.2
ADT
WDT
OPhoneSDK (including Emulator)
Pay attention to the installation steps of * to set Android SDK Location in Eclipse.
3 create a simple OPhone program
Create an Android project in Eclipse.
There are the following options to fill in:
Project Name: project name.
Package name: namespace.
Activity name: understand it as the entry class of the program first and explain it later.
Application name: program name.
Remember to join android.jar and oms.jar.
4. OPhone directory structure and its significance
The created OPhone project has the following basic structure.
Src:java code .
Resources for res:OPhone.
Res\ drawable: picture.
Res\ layout: layout description.
Res\ values: string definition.
AndroidManifest.xml: describes the OPhone program.
(5) key concepts of OPhone.
Deployment related:
Although we developed it in java, the result is not the usual jar, but dex, or apk.
The process is that we write java, compile it to class, optimize it to dex (mobile is still a relatively restricted environment), and package it into an apk file with resources. It is executed by Dalvik VM after deployment.
An Ophone application is a collection of multiple Activity. You can specify the entry Activity for this Ophone App in AndroidManifest.xml.
An Activity is a basic interaction stream with users and has its own life cycle. Information can be transmitted between Activity through Intent.
For more information about the life cycle of Activity, please see
Http://code.google.com/p/androidbmi/wiki/LifeCycle
An implementation of Activity uses MVC, where the code part is responsible for MC,res\ layout and the xml is responsible for View.
The strings used in App can be uniformly maintained in xml under res\ values to facilitate system maintenance and management.
The project automatically generates a R.java to manage resource-related references. Developers do not need to modify the file manually.
6 screenshots of small examples.
The function of this example is that the user enters a name, and the program says hello to the user.
7 key code interpretation
HelloOPhone defines the entry Activity.
Echo defines an Activity to say hello.
Take a look at how the View part of HelloOPhone is defined. Xml is so self-describing that it doesn't have to be explained.
Xml code
< 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="@string/input_msg" /> < EditText android:id="@+id/name" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="" /> < Button android:id="@+id/ok" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/ok" /> < /LinearLayout>See how an Activity is associated with this xml. Through the definition in the automatically generated R.java. Note that the defined xml file name change R will be automatically refreshed.
Java code
SetContentView (R.layout.input)
Then take a look at how an Activity finds the View through the id in xml.
Java code
B_ok = (Button) findViewById (R.id.ok)
And see how Activity launches another Echo Activity through Intent and sends a message to that Activity.
Java code
Intent intent = new Intent (); intent.setClass (HelloOPhone.this, Echo.class); Bundle bundle = new Bundle (); bundle.putString ("name", name); intent.putExtras (bundle); startActivity (intent)
Then take a look at how Echo receives the transmitted message.
Java code
Bundle bunde = this.getIntent () .getExtras (); String name = bunde.getString ("name")
* simply see how AndroidManifest.xml describes the app.
It indicates the namespace, the image of the program, and so on.
At the same time, it is pointed out that the app is composed of two Activity, and HelloOPhone is set as the entry Activity.
Xml code
< manifest xmlns:android="http://schemas.android.com/apk/res/android" package="allen.oms" android:versionCode="1" android:versionName="1.0.0"> < application android:icon="@drawable/icon" android:label="@string/app_name"> < activity android:name=".HelloOPhone" android:label="@string/app_name"> < intent-filter> < action android:name="android.intent.action.MAIN" /> < category android:name="android.intent.category.LAUNCHER" /> < /intent-filter> < /activity> < activity android:name=".Echo" android:label="@string/app_name" /> < /application> < /manifest>The above is how to get started quickly with Ophone and Android. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.