Bài giảng Android nâng cao: Bài 4 Media Services (continue) + Location Base Services cung cấp cho người học những kiến thức như: Media Services (continue); Global Positioning Services; Geocoding Locations; Mapping Locations. Mời các bạn cùng tham khảo!
Trang 1ANDROID NÂNG CAO
BÀI 4: Media Services (continue) +
Location Base Services
Trang 22 Location Base Services
– Global Positioning Services
– Geocoding Locations
– Mapping Locations
Trang 3P à1.1
Trang 5VideoView + MediaController
V V à à à à à à à à à
à à à start , pause , suspend , resume ,
stopPlayback , seekTo (millis)
Trang 10MediaPlayer + SurfaceView
public class MainActivity extends Activity
implements SurfaceHolder.Callback, OnPreparedListener {
private MediaPlayer mediaPlayer;
protected void onCreate(Bundle savedInstanceState) {
Trang 11public void onPrepared(MediaPlayer mp) { mediaPlayer.start(); }}
Trang 12Text to speech
Trang 14Text to speech
g i activity m c đ nh đ ki m tra có d li u cho TTS ch a
Intent intent = new Intent(Engine.ACTION_CHECK_TTS_DATA);
// d li u đã có t o đ i t ng TTS m c đ nh}
}
Trang 15Text to speech
TextToSpeech talker = new TextToSpeech(this, new OnInitListener() {
public void onInit(int status) {
talker speak Hi There TextToSpeech QUEUE FLUSH null}
}
TextToSpeech tts = new TextToSpeech(this, new OnInitListener() {
public void onInit(int status) {
if (status != TextToSpeech.SUCCESS) return;
Trang 16Camera
Trang 171 Previewing
2 After shutter is pressed
3 Image transferred from
Trang 18mImageView = (ImageView) findViewById(R.id.mImageView);
Intent mIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);startActivityForResult(mIntent, 101);
}
private void showToast(Context context, String text) {
Toast.makeText(context, text, 1).show();
}
Trang 19C à à à à
protected void onActivityResult(int req, int res, Intent intent) {
super.onActivityResult(req, res, intent);
if (res == RESULT_CANCELED) return;
}
Trang 20<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
Trang 21The takePicture Method
Trang 22Global Positioning Services
P à2.1
Trang 23Global Positioning Services
Trang 24Global Positioning Services
< uses-feature android:name ="android.hardware.location" />
< uses-feature android:name ="android.hardware.location.gps" />
Trang 26Location services: example
Trang 27Location services: example
Trang 28Location services: example
Trang 29Location services: i ch
Thông qua LocationManager à à y c u
– List<String> getAllProviders (): y t àprovider
– String getBestProviders (Criteria, enableOnly): y provider à
p t i u n
• Criteria: power, accuracy, speed, altitude– LocationProvider getProvider (name): L y provider theo tên
– requestLocationUpdate (providerName, minTime,
minDistance, listener): Yêu u i listener i minTime giây c provider t n ch n midDistance t
Trang 30mili-Geocoding Locations
Trang 32Geocoding Locations - example
Trang 33Geocoding Locations - example
Trang 34Geocoding Locations - example
Trang 35Mapping Locations
P à2.3
Trang 37Google Maps bên ngoài
Trang 38<uses-permission android:name="android.permission.INTERNET" />
Trang 40 Trong AndroidManifest.xml, n <application>, à
sung thêm các dòng sau:
android:value="KEY"/>
android:value="@integer/google_play_services_version" />