Download - android level 3
![Page 1: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/1.jpg)
Level 3
android camp
![Page 2: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/2.jpg)
Maps ,Location-based Services
&Telephony API
![Page 3: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/3.jpg)
![Page 4: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/4.jpg)
The location-based services facility in Android sits on two pillars:
1-mappingmapping using the package com.google.android.maps,
2-Location-based APIsLocation-based APIs.using the package android.location
![Page 5: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/5.jpg)
All we need to start is :All we need to start is :
1-Internet connection
2-accept the terms of google
Then , let's develop :D
![Page 6: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/6.jpg)
Understanding the Mapping Package
Obtain your MD5 fingerprint
Obtaining a mapapi Key from Google (two keys) one for development with the emulator and another for production
Understanding MapView and MapActivity
![Page 7: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/7.jpg)
Let's get our MD5 locate your debug certificate
![Page 8: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/8.jpg)
Let's get our MD5
keytool -list -alias androiddebugkey -keystore"FULL PATH OF YOUR debug.keystore FILE" -storepass android -keypass android
Enter the password : android (only if asked)
![Page 9: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/9.jpg)
Get your API-key now
Use the link http://code.google.com/android/mapsapisignup.html
Then enter your MD5 and accept the terms
![Page 10: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/10.jpg)
Now let's code :D
![Page 11: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/11.jpg)
Now let's code :Dmainfest.xml
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.ashour.amar.map3" android:versionCode="1" android:versionName="1.0" >
<uses-sdk android:minSdkVersion="4" />
<<uses-permissionuses-permission android:nameandroid:name=="android.permission.INTERNET""android.permission.INTERNET" />/>
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <<uses-libraryuses-library android:nameandroid:name=="com.google.android.maps""com.google.android.maps" />/>
<activity android:label="@string/app_name" android:name=".Map3Activity" > <intent-filter > <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application>
</manifest>
![Page 12: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/12.jpg)
Now let's code :Dadd this at your layout
<com.google.android.maps.MapView android:id="@+id/mapview" android:layout_width="fill_parent" android:layout_height="wrap_content" android:apiKey="0HjFnVeWB501OoE879ht4U35shuIsabH6M5UUUw" android:clickable="true" />
![Page 13: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/13.jpg)
Now let's code :DjavaActivity
public class Map2Activity extends MapActivity{ private MapView mapView;private GeoPoint pt;
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mapView = (MapView)findViewById(R.id.mapview); mapView.setBuiltInZoomControls(true); } @Override protected boolean isLocationDisplayed() { return true; }@Overrideprotected boolean isRouteDisplayed() {return true;}}
![Page 14: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/14.jpg)
TELEPHONY API
With the telephony API you can work with messages , make calls and use the Internet to make calls VOIP
![Page 15: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/15.jpg)
Now let's make SMS sender app :D
![Page 16: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/16.jpg)
Send messages
You will use android.telephony.SmsManager class
Dont forget to add the permission android.permission.SEND_SMSandroid.permission.SEND_SMS
![Page 17: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/17.jpg)
Sms codelayout code
<?xml version="1.0" encoding="utf-8"?><!-- This file is /res/layout/main.xml --><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" >
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Destination Address:" />
<EditText android:id="@+id/addrEditText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:phoneNumber="true" android:text="01095996548" /> </LinearLayout>
![Page 18: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/18.jpg)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" >
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Text Message:" />
<EditText android:id="@+id/msgEditText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="hello sms" /> </LinearLayout>
<Button android:id="@+id/sendSmsBtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="doSend" android:text="Send Text Message" />
</LinearLayout>
![Page 19: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/19.jpg)
Sms codeactivity code
public class SmsActivity extends Activity {/** Called when the activity is first created. */@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);}
public void doSend(View view) {EditText addrTxt = (EditText) findViewById(R.id.addrEditText);EditText msgTxt = (EditText) findViewById(R.id.msgEditText);try {sendSmsMessage(addrTxt.getText().toString(), msgTxt.getText().toString());Toast.makeText(this, "SMS Sent", Toast.LENGTH_LONG).show();} catch (Exception e) {Toast.makeText(this, "Failed to send SMS", Toast.LENGTH_LONG).show();e.printStackTrace();}}
![Page 20: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/20.jpg)
@Overrideprotected void onDestroy() {super.onDestroy();}
private void sendSmsMessage(String address, String message)throws Exception {SmsManager smsMgr = SmsManager.getDefault();smsMgr.sendTextMessage(address, null, message, null, null);}}
![Page 21: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/21.jpg)
I think you know your way now
![Page 22: android level 3](https://reader034.vdocuments.site/reader034/viewer/2022052619/5558022fd8b42a200d8b52d1/html5/thumbnails/22.jpg)
Good books you can use
pro android 3 (my best ) OReilly Learning Android professional android application development Pro Android Media Developing Graphics