SlideShare une entreprise Scribd logo
1  sur  37
First Android App
Create a Android Project
File > Android
Application Project
Android App Name
Eclipse Project Name
App Package Name Google play package is only
Running Your First App
Introduction directories and files in the Android
project
The first Android project architecture
http://developer.android.com/tools/projects/index.html
AndroidManifest.xml
<?xml	
  version="1.0"	
  encoding="utf-­‐8"?>	
  
<manifest	
  xmlns:android="http://schemas.android.com/apk/res/android"	
  
	
  	
  	
  	
  package="com.example.firstapp"	
  
	
  	
  	
  	
  android:versionCode="1"	
  
	
  	
  	
  	
  android:versionName="1.0"	
  >	
  
!
	
  	
  	
  	
  <uses-­‐sdk	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:minSdkVersion="8"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:targetSdkVersion="21"	
  />	
  
!
	
  	
  	
  	
  <application	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:allowBackup="true"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:icon="@drawable/ic_launcher"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:label="@string/app_name"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:theme="@style/AppTheme"	
  >	
  
	
  	
  	
  	
  	
  	
  	
  	
  <activity	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  android:name=".MainActivity"	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  android:label="@string/app_name"	
  >	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <intent-­‐filter>	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <action	
  android:name="android.intent.action.MAIN"	
  />	
  
!
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <category	
  android:name="android.intent.category.LAUNCHER"	
  />	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  </intent-­‐filter>	
  
	
  	
  	
  	
  	
  	
  	
  	
  </activity>	
  
	
  	
  	
  	
  </application>	
  
!
</manifest>
AndroidManifest.xml
<?xml	
  version="1.0"	
  encoding="utf-­‐8"?>	
  
<manifest	
  xmlns:android="http://schemas.android.com/apk/res/android"	
  
	
  	
  	
  	
  package="com.example.firstapp"	
  
	
  	
  	
  	
  android:versionCode="1"	
  
	
  	
  	
  	
  android:versionName="1.0"	
  >	
  
!
	
  	
  	
  	
  <uses-­‐sdk	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:minSdkVersion="8"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:targetSdkVersion="21"	
  />	
  
!
	
  	
  	
  	
  <application	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:allowBackup="true"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:icon="@drawable/ic_launcher"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:label="@string/app_name"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:theme="@style/AppTheme"	
  >	
  
	
  	
  	
  	
  	
  	
  	
  	
  <activity	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  android:name=".MainActivity"	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  android:label="@string/app_name"	
  >	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <intent-­‐filter>	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <action	
  android:name="android.intent.action.MAIN"	
  />	
  
!
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <category	
  android:name="android.intent.category.LAUNCHER"	
  />	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  </intent-­‐filter>	
  
	
  	
  	
  	
  	
  	
  	
  	
  </activity>	
  
	
  	
  	
  	
  </application>	
  
!
</manifest>
AndroidManifest.xml
<?xml	
  version="1.0"	
  encoding="utf-­‐8"?>	
  
<manifest	
  xmlns:android="http://schemas.android.com/apk/res/android"	
  
	
  	
  	
  	
  package="com.example.firstapp"	
  
	
  	
  	
  	
  android:versionCode="1"	
  
	
  	
  	
  	
  android:versionName="1.0"	
  >	
  
!
	
  	
  	
  	
  <uses-­‐sdk	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:minSdkVersion="8"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:targetSdkVersion="21"	
  />	
  
!
	
  	
  	
  	
  <application	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:allowBackup="true"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:icon="@drawable/ic_launcher"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:label="@string/app_name"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:theme="@style/AppTheme"	
  >	
  
	
  	
  	
  	
  	
  	
  	
  	
  <activity	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  android:name=".MainActivity"	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  android:label="@string/app_name"	
  >	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <intent-­‐filter>	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <action	
  android:name="android.intent.action.MAIN"	
  />	
  
!
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <category	
  android:name="android.intent.category.LAUNCHER"	
  />	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  </intent-­‐filter>	
  
	
  	
  	
  	
  	
  	
  	
  	
  </activity>	
  
	
  	
  	
  	
  </application>	
  
!
</manifest>
AndroidManifest.xml
<?xml	
  version="1.0"	
  encoding="utf-­‐8"?>	
  
<manifest	
  xmlns:android="http://schemas.android.com/apk/res/android"	
  
	
  	
  	
  	
  package="com.example.firstapp"	
  
	
  	
  	
  	
  android:versionCode="1"	
  
	
  	
  	
  	
  android:versionName="1.0"	
  >	
  
!
	
  	
  	
  	
  <uses-­‐sdk	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:minSdkVersion="8"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:targetSdkVersion="21"	
  />	
  
!
	
  	
  	
  	
  <application	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:allowBackup="true"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:icon="@drawable/ic_launcher"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:label="@string/app_name"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:theme="@style/AppTheme"	
  >	
  
	
  	
  	
  	
  	
  	
  	
  	
  <activity	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  android:name=".MainActivity"	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  android:label="@string/app_name"	
  >	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <intent-­‐filter>	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <action	
  android:name="android.intent.action.MAIN"	
  />	
  
!
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <category	
  android:name="android.intent.category.LAUNCHER"	
  />	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  </intent-­‐filter>	
  
	
  	
  	
  	
  	
  	
  	
  	
  </activity>	
  
	
  	
  	
  	
  </application>	
  
!
</manifest>
res/values/string.xml
<?xml	
  version="1.0"	
  encoding="utf-­‐8"?>	
  
<manifest	
  xmlns:android="http://schemas.android.com/apk/res/android"	
  
	
  	
  	
  	
  package="com.example.firstapp"	
  
	
  	
  	
  	
  android:versionCode="1"	
  
	
  	
  	
  	
  android:versionName="1.0"	
  >	
  
!
	
  	
  	
  	
  <uses-­‐sdk	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:minSdkVersion="8"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:targetSdkVersion="21"	
  />	
  
!
	
  	
  	
  	
  <application	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:allowBackup="true"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:icon="@drawable/ic_launcher"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:label="@string/app_name"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:theme="@style/AppTheme"	
  >	
  
	
  	
  	
  	
  	
  	
  	
  	
  <activity	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  android:name=".MainActivity"	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  android:label="@string/app_name"	
  >	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <intent-­‐filter>	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <action	
  android:name="android.intent.action.MAIN"	
  />	
  
!
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <category	
  android:name="android.intent.category.LAUNCHER"	
  />	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  </intent-­‐filter>	
  
	
  	
  	
  	
  	
  	
  	
  	
  </activity>	
  
	
  	
  	
  	
  </application>	
  
!
</manifest>
res/values/string.xml
<?xml	
  version="1.0"	
  encoding="utf-­‐8"?>	
  
<manifest	
  xmlns:android="http://schemas.android.com/apk/res/android"	
  
	
  	
  	
  	
  package="com.example.firstapp"	
  
	
  	
  	
  	
  android:versionCode="1"	
  
	
  	
  	
  	
  android:versionName="1.0"	
  >	
  
!
	
  	
  	
  	
  <uses-­‐sdk	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:minSdkVersion="8"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:targetSdkVersion="21"	
  />	
  
!
	
  	
  	
  	
  <application	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:allowBackup="true"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:icon="@drawable/ic_launcher"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:label="@string/app_name"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:theme="@style/AppTheme"	
  >	
  
	
  	
  	
  	
  	
  	
  	
  	
  <activity	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  android:name=".MainActivity"	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  android:label="@string/app_name"	
  >	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <intent-­‐filter>	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <action	
  android:name="android.intent.action.MAIN"	
  />	
  
!
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <category	
  android:name="android.intent.category.LAUNCHER"	
  />	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  </intent-­‐filter>	
  
	
  	
  	
  	
  	
  	
  	
  	
  </activity>	
  
	
  	
  	
  	
  </application>	
  
!
</manifest>
<?xml	
  version="1.0"	
  encoding="utf-­‐8"?>	
  
<resources>	
  
!
	
  	
  	
  	
  <string	
  name="app_name">FirstApp</string>	
  
	
  	
  	
  	
  <string	
  name="hello_world">Hello	
  world!</string>	
  
	
  	
  	
  	
  <string	
  name="action_settings">Settings</string>	
  
!
</resources>
res/values/string.xml
<?xml	
  version="1.0"	
  encoding="utf-­‐8"?>	
  
<manifest	
  xmlns:android="http://schemas.android.com/apk/res/android"	
  
	
  	
  	
  	
  package="com.example.firstapp"	
  
	
  	
  	
  	
  android:versionCode="1"	
  
	
  	
  	
  	
  android:versionName="1.0"	
  >	
  
!
	
  	
  	
  	
  <uses-­‐sdk	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:minSdkVersion="8"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:targetSdkVersion="21"	
  />	
  
!
	
  	
  	
  	
  <application	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:allowBackup="true"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:icon="@drawable/ic_launcher"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:label="@string/app_name"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:theme="@style/AppTheme"	
  >	
  
	
  	
  	
  	
  	
  	
  	
  	
  <activity	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  android:name=".MainActivity"	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  android:label="@string/app_name"	
  >	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <intent-­‐filter>	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <action	
  android:name="android.intent.action.MAIN"	
  />	
  
!
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <category	
  android:name="android.intent.category.LAUNCHER"	
  />	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  </intent-­‐filter>	
  
	
  	
  	
  	
  	
  	
  	
  	
  </activity>	
  
	
  	
  	
  	
  </application>	
  
!
</manifest>
<?xml	
  version="1.0"	
  encoding="utf-­‐8"?>	
  
<resources>	
  
!
	
  	
  	
  	
  <string	
  name="app_name">FirstApp</string>	
  
	
  	
  	
  	
  <string	
  name="hello_world">Hello	
  world!</string>	
  
	
  	
  	
  	
  <string	
  name="action_settings">Settings</string>	
  
!
</resources>
AndroidManifest.xml
<?xml	
  version="1.0"	
  encoding="utf-­‐8"?>	
  
<manifest	
  xmlns:android="http://schemas.android.com/apk/res/android"	
  
	
  	
  	
  	
  package="com.example.firstapp"	
  
	
  	
  	
  	
  android:versionCode="1"	
  
	
  	
  	
  	
  android:versionName="1.0"	
  >	
  
!
	
  	
  	
  	
  <uses-­‐sdk	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:minSdkVersion="8"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:targetSdkVersion="21"	
  />	
  
!
	
  	
  	
  	
  <application	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:allowBackup="true"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:icon="@drawable/ic_launcher"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:label="@string/app_name"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:theme="@style/AppTheme"	
  >	
  
	
  	
  	
  	
  	
  	
  	
  	
  <activity	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  android:name=".MainActivity"	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  android:label="@string/app_name"	
  >	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <intent-­‐filter>	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <action	
  android:name="android.intent.action.MAIN"	
  />	
  
!
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  <category	
  android:name="android.intent.category.LAUNCHER"	
  />	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  </intent-­‐filter>	
  
	
  	
  	
  	
  	
  	
  	
  	
  </activity>	
  
	
  	
  	
  	
  </application>	
  
!
</manifest>
src/{your package name}/
MainActivity.java
public	
  class	
  MainActivity	
  extends	
  ActionBarActivity	
  {	
  
!
	
   @Override	
  
	
   protected	
  void	
  onCreate(Bundle	
  savedInstanceState)	
  {	
  
	
   	
   super.onCreate(savedInstanceState);	
  
	
   	
   setContentView(R.layout.activity_main);	
  
	
   }	
  
!
	
   @Override	
  
	
   public	
  boolean	
  onCreateOptionsMenu(Menu	
  menu)	
  {	
  
	
   	
   //	
  Inflate	
  the	
  menu;	
  this	
  adds	
  items	
  to	
  the	
  action	
  bar	
  if	
  it	
  is	
  present.	
  
	
   	
   getMenuInflater().inflate(R.menu.main,	
  menu);	
  
	
   	
   return	
  true;	
  
	
   }	
  
!
	
   @Override	
  
	
   public	
  boolean	
  onOptionsItemSelected(MenuItem	
  item)	
  {	
  
	
   	
   //	
  Handle	
  action	
  bar	
  item	
  clicks	
  here.	
  The	
  action	
  bar	
  will	
  
	
   	
   //	
  automatically	
  handle	
  clicks	
  on	
  the	
  Home/Up	
  button,	
  so	
  long	
  
	
   	
   //	
  as	
  you	
  specify	
  a	
  parent	
  activity	
  in	
  AndroidManifest.xml.	
  
	
   	
   int	
  id	
  =	
  item.getItemId();	
  
	
   	
   if	
  (id	
  ==	
  R.id.action_settings)	
  {	
  
	
   	
   	
   return	
  true;	
  
	
   	
   }	
  
	
   	
   return	
  super.onOptionsItemSelected(item);	
  
	
   }	
  
}
src/{your package name}/
MainActivity.java
public	
  class	
  MainActivity	
  extends	
  ActionBarActivity	
  {	
  
!
	
   @Override	
  
	
   protected	
  void	
  onCreate(Bundle	
  savedInstanceState)	
  {	
  
	
   	
   super.onCreate(savedInstanceState);	
  
	
   	
   setContentView(R.layout.activity_main);	
  
	
   }	
  
!
	
   @Override	
  
	
   public	
  boolean	
  onCreateOptionsMenu(Menu	
  menu)	
  {	
  
	
   	
   //	
  Inflate	
  the	
  menu;	
  this	
  adds	
  items	
  to	
  the	
  action	
  bar	
  if	
  it	
  is	
  present.	
  
	
   	
   getMenuInflater().inflate(R.menu.main,	
  menu);	
  
	
   	
   return	
  true;	
  
	
   }	
  
!
	
   @Override	
  
	
   public	
  boolean	
  onOptionsItemSelected(MenuItem	
  item)	
  {	
  
	
   	
   //	
  Handle	
  action	
  bar	
  item	
  clicks	
  here.	
  The	
  action	
  bar	
  will	
  
	
   	
   //	
  automatically	
  handle	
  clicks	
  on	
  the	
  Home/Up	
  button,	
  so	
  long	
  
	
   	
   //	
  as	
  you	
  specify	
  a	
  parent	
  activity	
  in	
  AndroidManifest.xml.	
  
	
   	
   int	
  id	
  =	
  item.getItemId();	
  
	
   	
   if	
  (id	
  ==	
  R.id.action_settings)	
  {	
  
	
   	
   	
   return	
  true;	
  
	
   	
   }	
  
	
   	
   return	
  super.onOptionsItemSelected(item);	
  
	
   }	
  
}
res/layout/activity_main.xml
public	
  class	
  MainActivity	
  extends	
  ActionBarActivity	
  {	
  
!
	
   @Override	
  
	
   protected	
  void	
  onCreate(Bundle	
  savedInstanceState)	
  {	
  
	
   	
   super.onCreate(savedInstanceState);	
  
	
   	
   setContentView(R.layout.activity_main);	
  
	
   }	
  
!
	
   @Override	
  
	
   public	
  boolean	
  onCreateOptionsMenu(Menu	
  menu)	
  {	
  
	
   	
   //	
  Inflate	
  the	
  menu;	
  this	
  adds	
  items	
  to	
  the	
  action	
  bar	
  if	
  it	
  is	
  present.	
  
	
   	
   getMenuInflater().inflate(R.menu.main,	
  menu);	
  
	
   	
   return	
  true;	
  
	
   }	
  
!
	
   @Override	
  
	
   public	
  boolean	
  onOptionsItemSelected(MenuItem	
  item)	
  {	
  
	
   	
   //	
  Handle	
  action	
  bar	
  item	
  clicks	
  here.	
  The	
  action	
  bar	
  will	
  
	
   	
   //	
  automatically	
  handle	
  clicks	
  on	
  the	
  Home/Up	
  button,	
  so	
  long	
  
	
   	
   //	
  as	
  you	
  specify	
  a	
  parent	
  activity	
  in	
  AndroidManifest.xml.	
  
	
   	
   int	
  id	
  =	
  item.getItemId();	
  
	
   	
   if	
  (id	
  ==	
  R.id.action_settings)	
  {	
  
	
   	
   	
   return	
  true;	
  
	
   	
   }	
  
	
   	
   return	
  super.onOptionsItemSelected(item);	
  
	
   }	
  
}
<RelativeLayout	
  xmlns:android="http://schemas.android.com/apk/
res/android"	
  
	
  	
  	
  	
  xmlns:tools="http://schemas.android.com/tools"	
  
	
  	
  	
  	
  android:layout_width="match_parent"	
  
	
  	
  	
  	
  android:layout_height="match_parent"	
  
	
  	
  	
  	
  android:paddingBottom="@dimen/activity_vertical_margin"	
  
	
  	
  	
  	
  android:paddingLeft="@dimen/activity_horizontal_margin"	
  
	
  	
  	
  	
  android:paddingRight="@dimen/activity_horizontal_margin"	
  
	
  	
  	
  	
  android:paddingTop="@dimen/activity_vertical_margin"	
  
	
  	
  	
  	
  tools:context="com.example.firstapp.MainActivity"	
  >	
  
!
	
  	
  	
  	
  <TextView	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:layout_width="wrap_content"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:layout_height="wrap_content"	
  
	
  	
  	
  	
  	
  	
  	
  	
  android:text="@string/hello_world"	
  />	
  
!
</RelativeLayout>
res gen src bin jni libs assets
layout
layout-land = 橫向

layout-port = 直向
drawable
xlarge = 960dp x 720dp

large = 640dp x 480dp

normal = 470dp x 320dp

small = 426dp x 320dp
menu Menu item
value
color.xml

string.xml

style.xml
res gen src bin jni libs assets
BuildConfig.java
/**	
  Automatically	
  generated	
  file.	
  DO	
  NOT	
  MODIFY	
  */	
  
package	
  com.example.firstapp;	
  
!
public	
  final	
  class	
  BuildConfig	
  {	
  
	
  	
  	
  	
  public	
  final	
  static	
  boolean	
  DEBUG	
  =	
  true;	
  
}
res gen src bin jni libs assets
R.java
AUTO-­‐GENERATED	
  FILE.	
  	
  DO	
  NOT	
  MODIFY.	
  
package	
  com.example.firstapp;	
  
!
public	
  final	
  class	
  R	
  {	
  
	
  	
  	
  	
  public	
  static	
  final	
  class	
  layout	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  public	
  static	
  final	
  int	
  activity_main=0x7f040000;	
  
	
  	
  	
  	
  }	
  
	
   	
  …………	
  
}
res gen src bin jni libs assets
package	
  com.example.firstapp;	
  
!
import	
  android.app.Activity;	
  
import	
  android.os.Bundle;	
  
!
public	
  class	
  MainActivity	
  extends	
  Activity	
  {	
  
!
	
   @Override	
  
	
   protected	
  void	
  onCreate(Bundle	
  savedInstanceState)	
  {	
  
	
   	
   super.onCreate(savedInstanceState);	
  
	
   	
   setContentView(R.layout.activity_main);	
  
	
   }	
  
!
}
res gen src bin jni libs assets
res gen src bin jni libs assets
res gen src bin jni libs assets
Third party library
res gen src bin jni libs assets
This is empty. You can use it to store raw asset files. Files
that you save here are compiled into an .apk file as-is,
and the original filename is preserved. You can navigate
this directory in the same way as a typical file system
using URIs and read files as a stream of bytes using the
AssetManager. For example, this is a good location for
textures and game data.
res gen src bin jni libs assets
Android Project Builder
res gen src bin jni libs assets

Contenu connexe

Tendances

Android app development basics
Android app development basicsAndroid app development basics
Android app development basics
Anton Narusberg
 
Android appwidget
Android appwidgetAndroid appwidget
Android appwidget
Krazy Koder
 

Tendances (20)

Android Life Cycle
Android Life CycleAndroid Life Cycle
Android Life Cycle
 
Android in practice
Android in practiceAndroid in practice
Android in practice
 
Android app development basics
Android app development basicsAndroid app development basics
Android app development basics
 
7 Ways to improve your gradle build
7 Ways to improve your gradle build7 Ways to improve your gradle build
7 Ways to improve your gradle build
 
Invading the home screen
Invading the home screenInvading the home screen
Invading the home screen
 
Hierarchy viewer
Hierarchy viewerHierarchy viewer
Hierarchy viewer
 
Android development orientation for starters v4 seminar
Android development orientation for starters v4   seminarAndroid development orientation for starters v4   seminar
Android development orientation for starters v4 seminar
 
Lesson 10
Lesson 10Lesson 10
Lesson 10
 
Android Development Made Easy - With Sample Project
Android Development Made Easy - With Sample ProjectAndroid Development Made Easy - With Sample Project
Android Development Made Easy - With Sample Project
 
Android Basics
Android BasicsAndroid Basics
Android Basics
 
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & MenusLearn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
 
Android studio
Android studioAndroid studio
Android studio
 
android level 3
android level 3android level 3
android level 3
 
Android Widget
Android WidgetAndroid Widget
Android Widget
 
Android appwidget
Android appwidgetAndroid appwidget
Android appwidget
 
Ionic으로 모바일앱 만들기 #3
Ionic으로 모바일앱 만들기 #3Ionic으로 모바일앱 만들기 #3
Ionic으로 모바일앱 만들기 #3
 
04 user interfaces
04 user interfaces04 user interfaces
04 user interfaces
 
Desenvolver para Chromecast
Desenvolver para ChromecastDesenvolver para Chromecast
Desenvolver para Chromecast
 
Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010
Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010
Droidcon: Sean Owen: Driving Downloads via Intents- 29/10/2010
 
Testing android apps with espresso
Testing android apps with espressoTesting android apps with espresso
Testing android apps with espresso
 

En vedette

2015-2016 IEEE-PROJECTS FOR ME-M.TECH-BE-BTECH-MCA-M.SC-COMPUTERSCIENCE-ENGIN...
2015-2016 IEEE-PROJECTS FOR ME-M.TECH-BE-BTECH-MCA-M.SC-COMPUTERSCIENCE-ENGIN...2015-2016 IEEE-PROJECTS FOR ME-M.TECH-BE-BTECH-MCA-M.SC-COMPUTERSCIENCE-ENGIN...
2015-2016 IEEE-PROJECTS FOR ME-M.TECH-BE-BTECH-MCA-M.SC-COMPUTERSCIENCE-ENGIN...
Irissolution
 

En vedette (7)

BPUT PROJECT LIST @ 2014-15
BPUT PROJECT LIST @ 2014-15BPUT PROJECT LIST @ 2014-15
BPUT PROJECT LIST @ 2014-15
 
2015-2016 IEEE-PROJECTS FOR ME-M.TECH-BE-BTECH-MCA-M.SC-COMPUTERSCIENCE-ENGIN...
2015-2016 IEEE-PROJECTS FOR ME-M.TECH-BE-BTECH-MCA-M.SC-COMPUTERSCIENCE-ENGIN...2015-2016 IEEE-PROJECTS FOR ME-M.TECH-BE-BTECH-MCA-M.SC-COMPUTERSCIENCE-ENGIN...
2015-2016 IEEE-PROJECTS FOR ME-M.TECH-BE-BTECH-MCA-M.SC-COMPUTERSCIENCE-ENGIN...
 
Simple Android Project (SAP)... A Test Application
Simple Android Project (SAP)... A Test ApplicationSimple Android Project (SAP)... A Test Application
Simple Android Project (SAP)... A Test Application
 
Restaurant Finder Android Application project Presentation
Restaurant Finder Android Application project PresentationRestaurant Finder Android Application project Presentation
Restaurant Finder Android Application project Presentation
 
Android College Application Project Report
Android College Application Project ReportAndroid College Application Project Report
Android College Application Project Report
 
Final year project presentation in android application
Final year project presentation in android applicationFinal year project presentation in android application
Final year project presentation in android application
 
My Project Report Documentation with Abstract & Snapshots
My Project Report Documentation with Abstract & SnapshotsMy Project Report Documentation with Abstract & Snapshots
My Project Report Documentation with Abstract & Snapshots
 

Similaire à Ch2 first app

Androidoscon20080721 1216843094441821-9
Androidoscon20080721 1216843094441821-9Androidoscon20080721 1216843094441821-9
Androidoscon20080721 1216843094441821-9
Gustavo Fuentes Zurita
 
Androidoscon20080721 1216843094441821-9
Androidoscon20080721 1216843094441821-9Androidoscon20080721 1216843094441821-9
Androidoscon20080721 1216843094441821-9
Gustavo Fuentes Zurita
 
Mobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 AndroidMobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 Android
Mohammad Shaker
 

Similaire à Ch2 first app (20)

Share kmu itbz_20181106
Share kmu itbz_20181106Share kmu itbz_20181106
Share kmu itbz_20181106
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development Practices
 
Creation of simple application using - step by step
Creation of simple application using - step by stepCreation of simple application using - step by step
Creation of simple application using - step by step
 
Lecture #1 Creating your first android project
Lecture #1  Creating your first android projectLecture #1  Creating your first android project
Lecture #1 Creating your first android project
 
Basics and different xml files used in android
Basics and different xml files used in androidBasics and different xml files used in android
Basics and different xml files used in android
 
Androidoscon20080721 1216843094441821-9
Androidoscon20080721 1216843094441821-9Androidoscon20080721 1216843094441821-9
Androidoscon20080721 1216843094441821-9
 
Androidoscon20080721 1216843094441821-9
Androidoscon20080721 1216843094441821-9Androidoscon20080721 1216843094441821-9
Androidoscon20080721 1216843094441821-9
 
Android Bootcamp Tanzania: android manifest
Android Bootcamp Tanzania: android manifestAndroid Bootcamp Tanzania: android manifest
Android Bootcamp Tanzania: android manifest
 
Android LAb - Creating an android app with Radio button
Android LAb - Creating an android app with Radio buttonAndroid LAb - Creating an android app with Radio button
Android LAb - Creating an android app with Radio button
 
How to Setup App Indexation
How to Setup App IndexationHow to Setup App Indexation
How to Setup App Indexation
 
04 activities - Android
04   activities - Android04   activities - Android
04 activities - Android
 
An Introduction to Deep Linking and App Indexing Codelab
An Introduction to Deep Linking and App Indexing CodelabAn Introduction to Deep Linking and App Indexing Codelab
An Introduction to Deep Linking and App Indexing Codelab
 
Services
ServicesServices
Services
 
Mobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 AndroidMobile Software Engineering Crash Course - C03 Android
Mobile Software Engineering Crash Course - C03 Android
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android Apps
 
4.preference management
4.preference management 4.preference management
4.preference management
 
Android Tutorials : Basic widgets
Android Tutorials : Basic widgetsAndroid Tutorials : Basic widgets
Android Tutorials : Basic widgets
 
Practical 14 android.docx
Practical 14 android.docxPractical 14 android.docx
Practical 14 android.docx
 
Android Programming.pptx
Android Programming.pptxAndroid Programming.pptx
Android Programming.pptx
 
Android Development Basics
Android Development BasicsAndroid Development Basics
Android Development Basics
 

Plus de Chia Wei Tsai

iHelp-台北警政局分享
iHelp-台北警政局分享iHelp-台北警政局分享
iHelp-台北警政局分享
Chia Wei Tsai
 
iHELP @ Taipei Google Develop Group mobile day
iHELP @ Taipei Google Develop Group mobile dayiHELP @ Taipei Google Develop Group mobile day
iHELP @ Taipei Google Develop Group mobile day
Chia Wei Tsai
 
KSDG - iHelp 心路歷程
KSDG - iHelp 心路歷程KSDG - iHelp 心路歷程
KSDG - iHelp 心路歷程
Chia Wei Tsai
 

Plus de Chia Wei Tsai (19)

iHelp & Open Data
iHelp & Open DataiHelp & Open Data
iHelp & Open Data
 
從競賽到創業
從競賽到創業從競賽到創業
從競賽到創業
 
沒有 GUI 的 Git
沒有 GUI 的 Git沒有 GUI 的 Git
沒有 GUI 的 Git
 
GDGK (LT) - Git 工作流程
GDGK (LT) - Git 工作流程GDGK (LT) - Git 工作流程
GDGK (LT) - Git 工作流程
 
人生歷程
人生歷程人生歷程
人生歷程
 
人生歷程
人生歷程人生歷程
人生歷程
 
聲點典(第一版)
聲點典(第一版)聲點典(第一版)
聲點典(第一版)
 
KSDG-iSlide App 開發心得分享
KSDG-iSlide App 開發心得分享KSDG-iSlide App 開發心得分享
KSDG-iSlide App 開發心得分享
 
iHelp-資訊服務創新應用競賽
iHelp-資訊服務創新應用競賽iHelp-資訊服務創新應用競賽
iHelp-資訊服務創新應用競賽
 
Mopcon2014(LT)
Mopcon2014(LT)Mopcon2014(LT)
Mopcon2014(LT)
 
iHelp-台經院
iHelp-台經院iHelp-台經院
iHelp-台經院
 
iHelp(交點)
iHelp(交點)iHelp(交點)
iHelp(交點)
 
iHelp-台北警政局分享
iHelp-台北警政局分享iHelp-台北警政局分享
iHelp-台北警政局分享
 
IHelp@Taiwan - App 創意搖籃
IHelp@Taiwan - App 創意搖籃 IHelp@Taiwan - App 創意搖籃
IHelp@Taiwan - App 創意搖籃
 
IHELP@KSDG
IHELP@KSDG IHELP@KSDG
IHELP@KSDG
 
iHELP @ Taipei Google Develop Group mobile day
iHELP @ Taipei Google Develop Group mobile dayiHELP @ Taipei Google Develop Group mobile day
iHELP @ Taipei Google Develop Group mobile day
 
iHELP
iHELPiHELP
iHELP
 
Word教材
Word教材Word教材
Word教材
 
KSDG - iHelp 心路歷程
KSDG - iHelp 心路歷程KSDG - iHelp 心路歷程
KSDG - iHelp 心路歷程
 

Dernier

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Dernier (20)

HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 

Ch2 first app

  • 6. App Package Name Google play package is only
  • 7.
  • 8.
  • 9.
  • 10.
  • 12.
  • 13.
  • 14.
  • 15. Introduction directories and files in the Android project
  • 16. The first Android project architecture http://developer.android.com/tools/projects/index.html
  • 17. AndroidManifest.xml <?xml  version="1.0"  encoding="utf-­‐8"?>   <manifest  xmlns:android="http://schemas.android.com/apk/res/android"          package="com.example.firstapp"          android:versionCode="1"          android:versionName="1.0"  >   !        <uses-­‐sdk                  android:minSdkVersion="8"                  android:targetSdkVersion="21"  />   !        <application                  android:allowBackup="true"                  android:icon="@drawable/ic_launcher"                  android:label="@string/app_name"                  android:theme="@style/AppTheme"  >                  <activity                          android:name=".MainActivity"                          android:label="@string/app_name"  >                          <intent-­‐filter>                                  <action  android:name="android.intent.action.MAIN"  />   !                                <category  android:name="android.intent.category.LAUNCHER"  />                          </intent-­‐filter>                  </activity>          </application>   ! </manifest>
  • 18. AndroidManifest.xml <?xml  version="1.0"  encoding="utf-­‐8"?>   <manifest  xmlns:android="http://schemas.android.com/apk/res/android"          package="com.example.firstapp"          android:versionCode="1"          android:versionName="1.0"  >   !        <uses-­‐sdk                  android:minSdkVersion="8"                  android:targetSdkVersion="21"  />   !        <application                  android:allowBackup="true"                  android:icon="@drawable/ic_launcher"                  android:label="@string/app_name"                  android:theme="@style/AppTheme"  >                  <activity                          android:name=".MainActivity"                          android:label="@string/app_name"  >                          <intent-­‐filter>                                  <action  android:name="android.intent.action.MAIN"  />   !                                <category  android:name="android.intent.category.LAUNCHER"  />                          </intent-­‐filter>                  </activity>          </application>   ! </manifest>
  • 19. AndroidManifest.xml <?xml  version="1.0"  encoding="utf-­‐8"?>   <manifest  xmlns:android="http://schemas.android.com/apk/res/android"          package="com.example.firstapp"          android:versionCode="1"          android:versionName="1.0"  >   !        <uses-­‐sdk                  android:minSdkVersion="8"                  android:targetSdkVersion="21"  />   !        <application                  android:allowBackup="true"                  android:icon="@drawable/ic_launcher"                  android:label="@string/app_name"                  android:theme="@style/AppTheme"  >                  <activity                          android:name=".MainActivity"                          android:label="@string/app_name"  >                          <intent-­‐filter>                                  <action  android:name="android.intent.action.MAIN"  />   !                                <category  android:name="android.intent.category.LAUNCHER"  />                          </intent-­‐filter>                  </activity>          </application>   ! </manifest>
  • 20. AndroidManifest.xml <?xml  version="1.0"  encoding="utf-­‐8"?>   <manifest  xmlns:android="http://schemas.android.com/apk/res/android"          package="com.example.firstapp"          android:versionCode="1"          android:versionName="1.0"  >   !        <uses-­‐sdk                  android:minSdkVersion="8"                  android:targetSdkVersion="21"  />   !        <application                  android:allowBackup="true"                  android:icon="@drawable/ic_launcher"                  android:label="@string/app_name"                  android:theme="@style/AppTheme"  >                  <activity                          android:name=".MainActivity"                          android:label="@string/app_name"  >                          <intent-­‐filter>                                  <action  android:name="android.intent.action.MAIN"  />   !                                <category  android:name="android.intent.category.LAUNCHER"  />                          </intent-­‐filter>                  </activity>          </application>   ! </manifest>
  • 21. res/values/string.xml <?xml  version="1.0"  encoding="utf-­‐8"?>   <manifest  xmlns:android="http://schemas.android.com/apk/res/android"          package="com.example.firstapp"          android:versionCode="1"          android:versionName="1.0"  >   !        <uses-­‐sdk                  android:minSdkVersion="8"                  android:targetSdkVersion="21"  />   !        <application                  android:allowBackup="true"                  android:icon="@drawable/ic_launcher"                  android:label="@string/app_name"                  android:theme="@style/AppTheme"  >                  <activity                          android:name=".MainActivity"                          android:label="@string/app_name"  >                          <intent-­‐filter>                                  <action  android:name="android.intent.action.MAIN"  />   !                                <category  android:name="android.intent.category.LAUNCHER"  />                          </intent-­‐filter>                  </activity>          </application>   ! </manifest>
  • 22. res/values/string.xml <?xml  version="1.0"  encoding="utf-­‐8"?>   <manifest  xmlns:android="http://schemas.android.com/apk/res/android"          package="com.example.firstapp"          android:versionCode="1"          android:versionName="1.0"  >   !        <uses-­‐sdk                  android:minSdkVersion="8"                  android:targetSdkVersion="21"  />   !        <application                  android:allowBackup="true"                  android:icon="@drawable/ic_launcher"                  android:label="@string/app_name"                  android:theme="@style/AppTheme"  >                  <activity                          android:name=".MainActivity"                          android:label="@string/app_name"  >                          <intent-­‐filter>                                  <action  android:name="android.intent.action.MAIN"  />   !                                <category  android:name="android.intent.category.LAUNCHER"  />                          </intent-­‐filter>                  </activity>          </application>   ! </manifest> <?xml  version="1.0"  encoding="utf-­‐8"?>   <resources>   !        <string  name="app_name">FirstApp</string>          <string  name="hello_world">Hello  world!</string>          <string  name="action_settings">Settings</string>   ! </resources>
  • 23. res/values/string.xml <?xml  version="1.0"  encoding="utf-­‐8"?>   <manifest  xmlns:android="http://schemas.android.com/apk/res/android"          package="com.example.firstapp"          android:versionCode="1"          android:versionName="1.0"  >   !        <uses-­‐sdk                  android:minSdkVersion="8"                  android:targetSdkVersion="21"  />   !        <application                  android:allowBackup="true"                  android:icon="@drawable/ic_launcher"                  android:label="@string/app_name"                  android:theme="@style/AppTheme"  >                  <activity                          android:name=".MainActivity"                          android:label="@string/app_name"  >                          <intent-­‐filter>                                  <action  android:name="android.intent.action.MAIN"  />   !                                <category  android:name="android.intent.category.LAUNCHER"  />                          </intent-­‐filter>                  </activity>          </application>   ! </manifest> <?xml  version="1.0"  encoding="utf-­‐8"?>   <resources>   !        <string  name="app_name">FirstApp</string>          <string  name="hello_world">Hello  world!</string>          <string  name="action_settings">Settings</string>   ! </resources>
  • 24. AndroidManifest.xml <?xml  version="1.0"  encoding="utf-­‐8"?>   <manifest  xmlns:android="http://schemas.android.com/apk/res/android"          package="com.example.firstapp"          android:versionCode="1"          android:versionName="1.0"  >   !        <uses-­‐sdk                  android:minSdkVersion="8"                  android:targetSdkVersion="21"  />   !        <application                  android:allowBackup="true"                  android:icon="@drawable/ic_launcher"                  android:label="@string/app_name"                  android:theme="@style/AppTheme"  >                  <activity                          android:name=".MainActivity"                          android:label="@string/app_name"  >                          <intent-­‐filter>                                  <action  android:name="android.intent.action.MAIN"  />   !                                <category  android:name="android.intent.category.LAUNCHER"  />                          </intent-­‐filter>                  </activity>          </application>   ! </manifest>
  • 25. src/{your package name}/ MainActivity.java public  class  MainActivity  extends  ActionBarActivity  {   !   @Override     protected  void  onCreate(Bundle  savedInstanceState)  {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);     }   !   @Override     public  boolean  onCreateOptionsMenu(Menu  menu)  {       //  Inflate  the  menu;  this  adds  items  to  the  action  bar  if  it  is  present.       getMenuInflater().inflate(R.menu.main,  menu);       return  true;     }   !   @Override     public  boolean  onOptionsItemSelected(MenuItem  item)  {       //  Handle  action  bar  item  clicks  here.  The  action  bar  will       //  automatically  handle  clicks  on  the  Home/Up  button,  so  long       //  as  you  specify  a  parent  activity  in  AndroidManifest.xml.       int  id  =  item.getItemId();       if  (id  ==  R.id.action_settings)  {         return  true;       }       return  super.onOptionsItemSelected(item);     }   }
  • 26. src/{your package name}/ MainActivity.java public  class  MainActivity  extends  ActionBarActivity  {   !   @Override     protected  void  onCreate(Bundle  savedInstanceState)  {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);     }   !   @Override     public  boolean  onCreateOptionsMenu(Menu  menu)  {       //  Inflate  the  menu;  this  adds  items  to  the  action  bar  if  it  is  present.       getMenuInflater().inflate(R.menu.main,  menu);       return  true;     }   !   @Override     public  boolean  onOptionsItemSelected(MenuItem  item)  {       //  Handle  action  bar  item  clicks  here.  The  action  bar  will       //  automatically  handle  clicks  on  the  Home/Up  button,  so  long       //  as  you  specify  a  parent  activity  in  AndroidManifest.xml.       int  id  =  item.getItemId();       if  (id  ==  R.id.action_settings)  {         return  true;       }       return  super.onOptionsItemSelected(item);     }   }
  • 27. res/layout/activity_main.xml public  class  MainActivity  extends  ActionBarActivity  {   !   @Override     protected  void  onCreate(Bundle  savedInstanceState)  {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);     }   !   @Override     public  boolean  onCreateOptionsMenu(Menu  menu)  {       //  Inflate  the  menu;  this  adds  items  to  the  action  bar  if  it  is  present.       getMenuInflater().inflate(R.menu.main,  menu);       return  true;     }   !   @Override     public  boolean  onOptionsItemSelected(MenuItem  item)  {       //  Handle  action  bar  item  clicks  here.  The  action  bar  will       //  automatically  handle  clicks  on  the  Home/Up  button,  so  long       //  as  you  specify  a  parent  activity  in  AndroidManifest.xml.       int  id  =  item.getItemId();       if  (id  ==  R.id.action_settings)  {         return  true;       }       return  super.onOptionsItemSelected(item);     }   } <RelativeLayout  xmlns:android="http://schemas.android.com/apk/ res/android"          xmlns:tools="http://schemas.android.com/tools"          android:layout_width="match_parent"          android:layout_height="match_parent"          android:paddingBottom="@dimen/activity_vertical_margin"          android:paddingLeft="@dimen/activity_horizontal_margin"          android:paddingRight="@dimen/activity_horizontal_margin"          android:paddingTop="@dimen/activity_vertical_margin"          tools:context="com.example.firstapp.MainActivity"  >   !        <TextView                  android:layout_width="wrap_content"                  android:layout_height="wrap_content"                  android:text="@string/hello_world"  />   ! </RelativeLayout>
  • 28. res gen src bin jni libs assets layout layout-land = 橫向 layout-port = 直向 drawable xlarge = 960dp x 720dp large = 640dp x 480dp normal = 470dp x 320dp small = 426dp x 320dp menu Menu item value color.xml string.xml style.xml
  • 29. res gen src bin jni libs assets BuildConfig.java /**  Automatically  generated  file.  DO  NOT  MODIFY  */   package  com.example.firstapp;   ! public  final  class  BuildConfig  {          public  final  static  boolean  DEBUG  =  true;   }
  • 30. res gen src bin jni libs assets R.java AUTO-­‐GENERATED  FILE.    DO  NOT  MODIFY.   package  com.example.firstapp;   ! public  final  class  R  {          public  static  final  class  layout  {                  public  static  final  int  activity_main=0x7f040000;          }      …………   }
  • 31. res gen src bin jni libs assets package  com.example.firstapp;   ! import  android.app.Activity;   import  android.os.Bundle;   ! public  class  MainActivity  extends  Activity  {   !   @Override     protected  void  onCreate(Bundle  savedInstanceState)  {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);     }   ! }
  • 32. res gen src bin jni libs assets
  • 33. res gen src bin jni libs assets
  • 34. res gen src bin jni libs assets Third party library
  • 35. res gen src bin jni libs assets This is empty. You can use it to store raw asset files. Files that you save here are compiled into an .apk file as-is, and the original filename is preserved. You can navigate this directory in the same way as a typical file system using URIs and read files as a stream of bytes using the AssetManager. For example, this is a good location for textures and game data.
  • 36. res gen src bin jni libs assets Android Project Builder
  • 37. res gen src bin jni libs assets