SlideShare a Scribd company logo
1 of 19
Download to read offline
6   Android      in




              Android 1.6




                       2010/10/16
                            sak+
2010/10/16




                                                                    Android         in

  2010/10/16




                                                                 sak         sak+

                                                       Android Market

                 R    digg                        B Lite            W Free/Pro/Quad      W Free/

Pro/Quad                         CF        Free        2010/09/26



Twitter
         @_sak
E-mail 
         sakashita                  sakplus.jp

Blog    
        http://sakplus.jp/blog/




  6    Android       in                                    Android 1.6   
                         1
2010/10/16




Step 1.

          Android

Eclipse                  File > New > Android Project                        New Android Project

                                                 Finish




Project name                                         SampleDialer

Build Target                                         1.6

Application name                                     SampleDialer

Package name                                         com.example.sampledialer

Create Activity                                      SampleDialer

Min SDK Version




Eclipse                  Run > Run As > Android Application




                    Hello World, SampleDialer!




 6   Android        in                                     Android 1.6   
                                 2
2010/10/16




src/com/example/sampledialer/SampleDialer.java

res/drawable-[hlm]dpi/icon.png

res/layout/main.xml

res/values/string.xml

AndroidManifest.xml




res/layout/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="@string/hello"
    />
</LinearLayout>




src/com/example/sampledialer/SampleDialer.java

public class SampleDialer extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}




       Step 1




 6   Android    in                               Android 1.6   
                   3
2010/10/16

Step 2.




                                                                   URI



SimpleCursorAdapter




src/com/example/sampledialer/SampleDialer.java

public class Sapporo01 extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

	         Cursor c =
              managedQuery(Contacts.Phones.CONTENT_URI, null, null, null, null);
	
          SimpleCursorAdapter adapter =
	           	 new SimpleCursorAdapter(
	           	 	     this,
	           	 	     android.R.layout.simple_list_item_2,
	           	 	     c,
	                   new String[] {
	           	     	 	     Contacts.Phones.NAME,
	           	     	 	     Contacts.Phones.NUMBER,
	           	 	     },
	                   new int[] {
	           	 	     	     android.R.id.text1,
	           	 	     	     android.R.id.text2,
	           	 	     }
	           	 );
	
          ListView lv = (ListView)findViewById(R.id.ListView01);
	         lv.setAdapter(adapter);
     }
}




 6   Android    in                               Android 1.6   
                   4
2010/10/16

ListView

res/layout/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"
    >
<ListView
    android:id="@+id/ListView01"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>
</LinearLayout>




AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.sampledialer"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon"
                 android:label="@string/app_name">
        <activity android:name=".Sapporo01" 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>

    <uses-permission android:name="android.permission.READ_CONTACTS" />
</manifest>




 6   Android    in                         Android 1.6   
                         5
2010/10/16




Step 3.




                                  SimpleCursorAdapter

                                          SimpleCursorAdapter



SampleDialer                                      SampleDialer.java

                                                                      ic_contact_picture.png

       res/layout/drawable-mdpi




 6   Android     in                                Android 1.6   
                               6
2010/10/16

src/com/example/sampledialer/SampleDialer.java
private class MyAdapter extends SimpleCursorAdapter{
    public MyAdapter(Context context, int layout,
                                 Cursor c, String[] from, int[] to) {
        super(context, layout, c, from, to);
        setViewBinder(new MyViewBinder());
    }
}

private class MyViewBinder implements SimpleCursorAdapter.ViewBinder {
	 @Override
	 public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
	 	
	 	 if (columnIndex == cursor.getColumnIndex(Contacts.Phones.PERSON_ID)) {
	      	 String person_id = cursor.getString(columnIndex);
	      	 if (person_id == null) {
	      	 	 ((ImageView)view).setImageResource(R.drawable.ic_contact_picture);
	      	 	 return true;
	      	}

	                	   Uri uri = ContentUris.withAppendedId(
	                	   	 	 Contacts.Photos.CONTENT_URI, Integer.parseInt(person_id));
	                	   String[] projection = { Contacts.Photos.DATA };
	                	
	                	   Cursor c = getContentResolver().query(uri, projection, null, null, null);
	                	   byte[] photoData = null;
	                	   if (c.moveToFirst()) {
	                	   	 photoData = c.getBlob(0);
	                	   }
	       	    	       c.close();
	       	    	
	       	    	       if (photoData != null) {
	       	    	       	 ((ImageView)view).setImageBitmap(
	       	    	       	 	 	 BitmapFactory.decodeByteArray(photoData, 0, photoData.length));
	       	    	       }
	       	    	       return true;
	
	       	    } else if (columnIndex == cursor.getColumnIndex(Contacts.Phones.TYPE)) {
	       	    	 String type;
	       	    	 int ntype = Integer.parseInt(cursor.getString(columnIndex));
	             	 if (ntype == 1) {
	             	 	 type = "    ";
	                	 } else if (ntype == 2) {
	                	 	 type = "    ";
	                	 } else if (ntype == 3) {
	                	 	 type = "    ";
	                	 } else {
	                	 	 type = "       ";
	              	}
	       	    	 ((TextView)view).setText(type);
	       	    	 return true;
	       	    }
	       	    return false;
	       }
}




    6       Android         in                              Android 1.6   
                          7
2010/10/16




                             simple_list_item_2

                                        ImageView

TextView                               item.xml




res/layout/item.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"
    >
<ImageView
    android:id="@+id/photo"
    android:layout_width="48dp"
    android:layout_height="48dp"
    android:src="@drawable/ic_contact_picture"/>
<TextView
    android:text="Name"
    android:id="@+id/name"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>
<TextView
    android:text="Number"
    android:id="@+id/number"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>
<TextView
    android:text="Type"
    android:id="@+id/type"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>
</LinearLayout>




 6   Android    in                         Android 1.6   
                         8
2010/10/16




src/com/example/sampledialer/SampleDialer.java
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

     Cursor c =
         managedQuery(Contacts.Phones.CONTENT_URI, null, null, null, null);

     MyAdapter adapter =
     	 new MyAdapter(
     	 	     this,
     	 	     R.layout.item,
     	 	     c,
             new String[] {
     	     	 	     Contacts.Phones.NAME,
     	     	 	     Contacts.Phones.NUMBER,
     	     	 	     Contacts.Phones.PERSON_ID,
     	     	 	     Contacts.Phones.TYPE,
     	 	     },
             new int[] {
     	 	     	     R.id.name,
     	 	     	     R.id.number,
     	 	     	     R.id.photo,
     	 	     	     R.id.type,
     	 	     }
     	 );

     ListView lv = (ListView)findViewById(R.id.ListView01);
     lv.setAdapter(adapter);
}




 6   Android   in                                Android 1.6   
                 9
2010/10/16




Step 4.

                              RelativeLayout

           RelativeLayout




 6   Android     in         Android 1.6   
           10
2010/10/16

res/layout/item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="2dp"
    >
<ImageView
    android:id="@+id/photo"
    android:layout_width="56dp"
    android:layout_height="56dp"
    android:src="@drawable/ic_contact_picture"/>
<TextView
    android:text="Name"
    android:id="@+id/name"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/photo"
    android:layout_marginTop="5dp"
    android:layout_marginLeft="10dp"
    android:maxWidth="190dp"
    android:singleLine="true"
    android:textSize="18dp"
    />
<TextView
    android:text="Number"
    android:id="@+id/number"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/photo"
    android:layout_below="@id/name"
    android:layout_marginTop="5dp"
    android:layout_marginLeft="15dp"
    android:textSize="14dp"
    />
<TextView
    android:text="Type"
    android:id="@+id/type"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/name"
    android:layout_marginTop="5dp"
    android:layout_marginRight="15dp"
    android:textSize="14dp"
    android:gravity="right"
    />
</RelativeLayout>




 6   Android    in                         Android 1.6   
                     11
2010/10/16




Step 5.




                              ACTION_DIAL

                    tel URI   tel:09012345678




 6   Android   in              Android 1.6   
          12
2010/10/16

src/com/example/sampledialer/SampleDialer.java
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);




     MyListView lv = (MyListView)findViewById(R.id.ListView01);
     lv.setDynamics(new SimpleDynamics(0.9f, 0.6f));
     lv.setAdapter(adapter);

     lv.setOnItemClickListener(new OnItemClickListener() {
         public void onItemClick(
             AdapterView<?> parent, View v, int position, long id) {
         	   call(id);
         }
     });
}

private void call(long id) {
    Uri uri = ContentUris.withAppendedId(Contacts.Phones.CONTENT_URI, id);
	
    Cursor c = getContentResolver().query(uri, null, null, null, null);
    c.moveToFirst();
    String number =
        (String)c.getString(c.getColumnIndex(Contacts.Phones.NUMBER));
    c.close();

     Intent i = new Intent(Intent.ACTION_DIAL);
     i.setData(Uri.parse("tel:" + number));
     startActivity(i);
}




 6   Android   in                                Android 1.6   
               13
2010/10/16




ACTION_DIAL           ACTION_CALL



AndroidManifest.xml

     <uses-permission android:name="android.permission.CALL_PHONE" />
     <uses-permission android:name="android.permission.CALL_PRIVILEGED" />




 6   Android   in                           Android 1.6   
                     14
2010/10/16




Step 1.

                                URL

http://blogs.sonyericsson.com/developerworld/2010/06/23/android-tutorial-making-your-own-3d-list-
part-3/




[Download] 3D List sample project – Part 3 (37kb)


                     ListTutrialPart3.zip




src/com/sonyericsson/tutrial/list3/MyListView.java

src/com/sonyericsson/tutrial/list3/TestActivity.java    SimpleDynamics
src/com/sonyericsson/util/Dynamics.java

res/drawable-ldpi/background.9.png




src                                     src                                   TestActivity.java

                                      SimpleDynamics                       SimpleDialer

                                                       TestActivity.java




          res/drawable-ldpi/backgrund.9.png                    res/drawable-mdpi




 6    Android       in                                 Android 1.6   
                                   15
2010/10/16

Step 2.




res/layout/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"
    >
    <com.sonyericsson.tutorial.list3.MyListView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/ListView01"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        />
</LinearLayout>




res/layout/item.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="2dp"
    android:background="@drawable/background"
    >




 6   Android    in                         Android 1.6   
                        16
2010/10/16

Step 3.

                          ListView




src/com/example/sampledialer/SampleDialer.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);




     MyListView lv = (MyListView)findViewById(R.id.ListView01);
     lv.setDynamics(new SimpleDynamics(0.9f, 0.6f));
     lv.setAdapter(adapter);

     lv.setOnItemClickListener(new OnItemClickListener() {
         public void onItemClick(
             AdapterView<?> parent, View v, int position, long id) {
         	   call(id);
         }
     });
}




 6   Android   in                                Android 1.6   
              17
2010/10/16




          Android

                     CF




6   Android     in        Android 1.6   
          18

More Related Content

What's hot

Mvp - типичные задачи и способ их решения в Moxy
Mvp - типичные задачи и способ их решения в MoxyMvp - типичные задачи и способ их решения в Moxy
Mvp - типичные задачи и способ их решения в MoxyYuri Shmakov
 
Android dev toolbox
Android dev toolboxAndroid dev toolbox
Android dev toolboxShem Magnezi
 
Architectures in the compose world
Architectures in the compose worldArchitectures in the compose world
Architectures in the compose worldFabio Collini
 
Android Testing
Android TestingAndroid Testing
Android TestingEvan Lin
 
Advancing the UI — Part 1: Look, Motion, and Gestures
Advancing the UI — Part 1: Look, Motion, and GesturesAdvancing the UI — Part 1: Look, Motion, and Gestures
Advancing the UI — Part 1: Look, Motion, and GesturesSamsung Developers
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsAhsanul Karim
 
Android programming -_pushing_the_limits
Android programming -_pushing_the_limitsAndroid programming -_pushing_the_limits
Android programming -_pushing_the_limitsDroidcon Berlin
 
Managing parallelism using coroutines
Managing parallelism using coroutinesManaging parallelism using coroutines
Managing parallelism using coroutinesFabio Collini
 

What's hot (13)

Mvp - типичные задачи и способ их решения в Moxy
Mvp - типичные задачи и способ их решения в MoxyMvp - типичные задачи и способ их решения в Moxy
Mvp - типичные задачи и способ их решения в Moxy
 
package org dev
package org devpackage org dev
package org dev
 
Android 3
Android 3Android 3
Android 3
 
Android App Dev Manual-1.doc
Android App Dev Manual-1.docAndroid App Dev Manual-1.doc
Android App Dev Manual-1.doc
 
Android dev toolbox
Android dev toolboxAndroid dev toolbox
Android dev toolbox
 
Ppt 2 android_basics
Ppt 2 android_basicsPpt 2 android_basics
Ppt 2 android_basics
 
Architectures in the compose world
Architectures in the compose worldArchitectures in the compose world
Architectures in the compose world
 
Android Testing
Android TestingAndroid Testing
Android Testing
 
Advancing the UI — Part 1: Look, Motion, and Gestures
Advancing the UI — Part 1: Look, Motion, and GesturesAdvancing the UI — Part 1: Look, Motion, and Gestures
Advancing the UI — Part 1: Look, Motion, and Gestures
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViews
 
Android programming -_pushing_the_limits
Android programming -_pushing_the_limitsAndroid programming -_pushing_the_limits
Android programming -_pushing_the_limits
 
Android Components
Android ComponentsAndroid Components
Android Components
 
Managing parallelism using coroutines
Managing parallelism using coroutinesManaging parallelism using coroutines
Managing parallelism using coroutines
 

Similar to ハンズオン資料 電話を作ろう(v1.6用)

android level 3
android level 3android level 3
android level 3DevMix
 
Unit5 Mobile Application Development.doc
Unit5 Mobile Application Development.docUnit5 Mobile Application Development.doc
Unit5 Mobile Application Development.docKNANTHINIMCA
 
MAD-Lec8 Spinner Adapater and Intents (1).ppt
MAD-Lec8 Spinner Adapater and Intents (1).pptMAD-Lec8 Spinner Adapater and Intents (1).ppt
MAD-Lec8 Spinner Adapater and Intents (1).pptAnsarAhmad57
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android AppsGil Irizarry
 
Building Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsBuilding Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsHassan Abid
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development PracticesRoy Clarkson
 
Android Development project
Android Development projectAndroid Development project
Android Development projectMinhaj Kazi
 
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 ProjectJoemarie Amparo
 
Synapseindia android apps introduction hello world
Synapseindia android apps introduction hello worldSynapseindia android apps introduction hello world
Synapseindia android apps introduction hello worldTarunsingh198
 
Android app development basics
Android app development basicsAndroid app development basics
Android app development basicsAnton Narusberg
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recieversUtkarsh Mankad
 
Hacking the Codename One Source Code - Part IV - Transcript.pdf
Hacking the Codename One Source Code - Part IV - Transcript.pdfHacking the Codename One Source Code - Part IV - Transcript.pdf
Hacking the Codename One Source Code - Part IV - Transcript.pdfShaiAlmog1
 
Android应用开发简介
Android应用开发简介Android应用开发简介
Android应用开发简介easychen
 
Workshop 26: React Native - The Native Side
Workshop 26: React Native - The Native SideWorkshop 26: React Native - The Native Side
Workshop 26: React Native - The Native SideVisual Engineering
 
How to use data binding in android
How to use data binding in androidHow to use data binding in android
How to use data binding in androidInnovationM
 
Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)Fafadia Tech
 
Design Patterns for Tablets and Smartphones
Design Patterns for Tablets and SmartphonesDesign Patterns for Tablets and Smartphones
Design Patterns for Tablets and SmartphonesMichael Galpin
 
ProTips DroidCon Paris 2013
ProTips DroidCon Paris 2013ProTips DroidCon Paris 2013
ProTips DroidCon Paris 2013Mathias Seguy
 

Similar to ハンズオン資料 電話を作ろう(v1.6用) (20)

android level 3
android level 3android level 3
android level 3
 
Ruby conf2012
Ruby conf2012Ruby conf2012
Ruby conf2012
 
Unit5 Mobile Application Development.doc
Unit5 Mobile Application Development.docUnit5 Mobile Application Development.doc
Unit5 Mobile Application Development.doc
 
MAD-Lec8 Spinner Adapater and Intents (1).ppt
MAD-Lec8 Spinner Adapater and Intents (1).pptMAD-Lec8 Spinner Adapater and Intents (1).ppt
MAD-Lec8 Spinner Adapater and Intents (1).ppt
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android Apps
 
Building Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture ComponentsBuilding Modern Apps using Android Architecture Components
Building Modern Apps using Android Architecture Components
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development Practices
 
Android Development project
Android Development projectAndroid Development project
Android Development project
 
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
 
Synapseindia android apps introduction hello world
Synapseindia android apps introduction hello worldSynapseindia android apps introduction hello world
Synapseindia android apps introduction hello world
 
Android app development basics
Android app development basicsAndroid app development basics
Android app development basics
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recievers
 
Hacking the Codename One Source Code - Part IV - Transcript.pdf
Hacking the Codename One Source Code - Part IV - Transcript.pdfHacking the Codename One Source Code - Part IV - Transcript.pdf
Hacking the Codename One Source Code - Part IV - Transcript.pdf
 
Android
AndroidAndroid
Android
 
Android应用开发简介
Android应用开发简介Android应用开发简介
Android应用开发简介
 
Workshop 26: React Native - The Native Side
Workshop 26: React Native - The Native SideWorkshop 26: React Native - The Native Side
Workshop 26: React Native - The Native Side
 
How to use data binding in android
How to use data binding in androidHow to use data binding in android
How to use data binding in android
 
Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)
 
Design Patterns for Tablets and Smartphones
Design Patterns for Tablets and SmartphonesDesign Patterns for Tablets and Smartphones
Design Patterns for Tablets and Smartphones
 
ProTips DroidCon Paris 2013
ProTips DroidCon Paris 2013ProTips DroidCon Paris 2013
ProTips DroidCon Paris 2013
 

Recently uploaded

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Recently uploaded (20)

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

ハンズオン資料 電話を作ろう(v1.6用)

  • 1. 6 Android in Android 1.6 2010/10/16 sak+
  • 2. 2010/10/16 Android in 2010/10/16 sak sak+ Android Market R digg B Lite W Free/Pro/Quad W Free/ Pro/Quad CF Free 2010/09/26 Twitter @_sak E-mail sakashita sakplus.jp Blog http://sakplus.jp/blog/ 6 Android in Android 1.6 1
  • 3. 2010/10/16 Step 1. Android Eclipse File > New > Android Project New Android Project Finish Project name SampleDialer Build Target 1.6 Application name SampleDialer Package name com.example.sampledialer Create Activity SampleDialer Min SDK Version Eclipse Run > Run As > Android Application Hello World, SampleDialer! 6 Android in Android 1.6 2
  • 4. 2010/10/16 src/com/example/sampledialer/SampleDialer.java res/drawable-[hlm]dpi/icon.png res/layout/main.xml res/values/string.xml AndroidManifest.xml res/layout/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="@string/hello" /> </LinearLayout> src/com/example/sampledialer/SampleDialer.java public class SampleDialer extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } } Step 1 6 Android in Android 1.6 3
  • 5. 2010/10/16 Step 2. URI SimpleCursorAdapter src/com/example/sampledialer/SampleDialer.java public class Sapporo01 extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Cursor c = managedQuery(Contacts.Phones.CONTENT_URI, null, null, null, null); SimpleCursorAdapter adapter = new SimpleCursorAdapter( this, android.R.layout.simple_list_item_2, c, new String[] { Contacts.Phones.NAME, Contacts.Phones.NUMBER, }, new int[] { android.R.id.text1, android.R.id.text2, } ); ListView lv = (ListView)findViewById(R.id.ListView01); lv.setAdapter(adapter); } } 6 Android in Android 1.6 4
  • 6. 2010/10/16 ListView res/layout/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" > <ListView android:id="@+id/ListView01" android:layout_width="fill_parent" android:layout_height="fill_parent"/> </LinearLayout> AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.sampledialer" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".Sapporo01" 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> <uses-permission android:name="android.permission.READ_CONTACTS" /> </manifest> 6 Android in Android 1.6 5
  • 7. 2010/10/16 Step 3. SimpleCursorAdapter SimpleCursorAdapter SampleDialer SampleDialer.java ic_contact_picture.png res/layout/drawable-mdpi 6 Android in Android 1.6 6
  • 8. 2010/10/16 src/com/example/sampledialer/SampleDialer.java private class MyAdapter extends SimpleCursorAdapter{ public MyAdapter(Context context, int layout, Cursor c, String[] from, int[] to) { super(context, layout, c, from, to); setViewBinder(new MyViewBinder()); } } private class MyViewBinder implements SimpleCursorAdapter.ViewBinder { @Override public boolean setViewValue(View view, Cursor cursor, int columnIndex) { if (columnIndex == cursor.getColumnIndex(Contacts.Phones.PERSON_ID)) { String person_id = cursor.getString(columnIndex); if (person_id == null) { ((ImageView)view).setImageResource(R.drawable.ic_contact_picture); return true; } Uri uri = ContentUris.withAppendedId( Contacts.Photos.CONTENT_URI, Integer.parseInt(person_id)); String[] projection = { Contacts.Photos.DATA }; Cursor c = getContentResolver().query(uri, projection, null, null, null); byte[] photoData = null; if (c.moveToFirst()) { photoData = c.getBlob(0); } c.close(); if (photoData != null) { ((ImageView)view).setImageBitmap( BitmapFactory.decodeByteArray(photoData, 0, photoData.length)); } return true; } else if (columnIndex == cursor.getColumnIndex(Contacts.Phones.TYPE)) { String type; int ntype = Integer.parseInt(cursor.getString(columnIndex)); if (ntype == 1) { type = " "; } else if (ntype == 2) { type = " "; } else if (ntype == 3) { type = " "; } else { type = " "; } ((TextView)view).setText(type); return true; } return false; } } 6 Android in Android 1.6 7
  • 9. 2010/10/16 simple_list_item_2 ImageView TextView item.xml res/layout/item.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" > <ImageView android:id="@+id/photo" android:layout_width="48dp" android:layout_height="48dp" android:src="@drawable/ic_contact_picture"/> <TextView android:text="Name" android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <TextView android:text="Number" android:id="@+id/number" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <TextView android:text="Type" android:id="@+id/type" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> 6 Android in Android 1.6 8
  • 10. 2010/10/16 src/com/example/sampledialer/SampleDialer.java @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Cursor c = managedQuery(Contacts.Phones.CONTENT_URI, null, null, null, null); MyAdapter adapter = new MyAdapter( this, R.layout.item, c, new String[] { Contacts.Phones.NAME, Contacts.Phones.NUMBER, Contacts.Phones.PERSON_ID, Contacts.Phones.TYPE, }, new int[] { R.id.name, R.id.number, R.id.photo, R.id.type, } ); ListView lv = (ListView)findViewById(R.id.ListView01); lv.setAdapter(adapter); } 6 Android in Android 1.6 9
  • 11. 2010/10/16 Step 4. RelativeLayout RelativeLayout 6 Android in Android 1.6 10
  • 12. 2010/10/16 res/layout/item.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="2dp" > <ImageView android:id="@+id/photo" android:layout_width="56dp" android:layout_height="56dp" android:src="@drawable/ic_contact_picture"/> <TextView android:text="Name" android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/photo" android:layout_marginTop="5dp" android:layout_marginLeft="10dp" android:maxWidth="190dp" android:singleLine="true" android:textSize="18dp" /> <TextView android:text="Number" android:id="@+id/number" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/photo" android:layout_below="@id/name" android:layout_marginTop="5dp" android:layout_marginLeft="15dp" android:textSize="14dp" /> <TextView android:text="Type" android:id="@+id/type" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_toRightOf="@id/name" android:layout_marginTop="5dp" android:layout_marginRight="15dp" android:textSize="14dp" android:gravity="right" /> </RelativeLayout> 6 Android in Android 1.6 11
  • 13. 2010/10/16 Step 5. ACTION_DIAL tel URI tel:09012345678 6 Android in Android 1.6 12
  • 14. 2010/10/16 src/com/example/sampledialer/SampleDialer.java @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); MyListView lv = (MyListView)findViewById(R.id.ListView01); lv.setDynamics(new SimpleDynamics(0.9f, 0.6f)); lv.setAdapter(adapter); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick( AdapterView<?> parent, View v, int position, long id) { call(id); } }); } private void call(long id) { Uri uri = ContentUris.withAppendedId(Contacts.Phones.CONTENT_URI, id); Cursor c = getContentResolver().query(uri, null, null, null, null); c.moveToFirst(); String number = (String)c.getString(c.getColumnIndex(Contacts.Phones.NUMBER)); c.close(); Intent i = new Intent(Intent.ACTION_DIAL); i.setData(Uri.parse("tel:" + number)); startActivity(i); } 6 Android in Android 1.6 13
  • 15. 2010/10/16 ACTION_DIAL ACTION_CALL AndroidManifest.xml <uses-permission android:name="android.permission.CALL_PHONE" /> <uses-permission android:name="android.permission.CALL_PRIVILEGED" /> 6 Android in Android 1.6 14
  • 16. 2010/10/16 Step 1. URL http://blogs.sonyericsson.com/developerworld/2010/06/23/android-tutorial-making-your-own-3d-list- part-3/ [Download] 3D List sample project – Part 3 (37kb) ListTutrialPart3.zip src/com/sonyericsson/tutrial/list3/MyListView.java src/com/sonyericsson/tutrial/list3/TestActivity.java SimpleDynamics src/com/sonyericsson/util/Dynamics.java res/drawable-ldpi/background.9.png src src TestActivity.java SimpleDynamics SimpleDialer TestActivity.java res/drawable-ldpi/backgrund.9.png res/drawable-mdpi 6 Android in Android 1.6 15
  • 17. 2010/10/16 Step 2. res/layout/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" > <com.sonyericsson.tutorial.list3.MyListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/ListView01" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout> res/layout/item.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="2dp" android:background="@drawable/background" > 6 Android in Android 1.6 16
  • 18. 2010/10/16 Step 3. ListView src/com/example/sampledialer/SampleDialer.java @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); MyListView lv = (MyListView)findViewById(R.id.ListView01); lv.setDynamics(new SimpleDynamics(0.9f, 0.6f)); lv.setAdapter(adapter); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick( AdapterView<?> parent, View v, int position, long id) { call(id); } }); } 6 Android in Android 1.6 17
  • 19. 2010/10/16 Android CF 6 Android in Android 1.6 18