Upload presentasi
Presentasi sedang didownload. Silahkan tunggu
1
Mendayagunakan Activity External
Pemrograman Bergerak Mendayagunakan Activity External 1
2
Pengaktifan Activity secara Implicit
Pengaktifan Activity secara Implicit memungkinkan kita untuk mendayagunakan Activity yang sudah tersedia pada aplikasi bawaan di Android maupun aplikasi- aplikasi yang memiliki intent-filter pada saat deklarasi Activity tersebut pada AndroidManifest. Scara umum untuk mendayagunakan Activity bawaan di Android: 1. Menggunakan Permisi pada AndroidManifest.xml 2, Mengirim intent dan uri ataupun data tambahan lainnya.
3
Melakukan Call Intent intent= new Intent(Intent.ACTION_CALL,Uri.parse("tel: ")); startActivity(intent); Anda perlu menggunakan CALL_PHONE permission pada AndroidManifest.XML <uses-permission android:name= "android.permission.CALL_PHONE"> </uses-permission>
4
Menampilkan Website Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(" startActivity(intent); Anda perlu menggunakan INTERNET permission pada AndroidManifest.xml <uses-permission android:name= "android.permission.INTERNET"> </uses-permission>
5
Mengirim Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("plain/text"); intent.putExtra(Intent.EXTRA_ ,new intent.putExtra(Intent.EXTRA_SUBJECT,"Hello World"); intent.putExtra(Intent.EXTRA_TEXT,"Selamat Pagi"); startActivity(Intent.createChooser(intent, "Send mail...")); Anda perlu menggunakan INTERNET permission pada AndroidManifest.xml <uses-permission android:name= "android.permission.INTERNET"> </uses-permission>
6
Mengirim SMS Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("sms: ")); intent.putExtra("sms_body","hello world"); startActivity(intent); Anda perlu menggunakan SEND_SMS permission pada AndroidManifest,XML <uses-permission android:name= "android.permission.SEND_SMS"> </uses-permission>
7
Mengaktifkan Google Map
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=medan")); StartActivity(intent); Mengaktifkan Google Map IBBI Kampus Topaz Uri.parse("geo: , ?z=19"));
8
Mengaktifkan Camera dan Capture
private static final int CAMERA_PIC_REQUEST = 1337; @Override public void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout.main); Button buttonCapture = (Button) findViewById(R.id.buttonCapture); buttonCapture.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); startActivityForResult(intent, CAMERA_PIC_REQUEST); } }); public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK && requestCode == CAMERA_PIC_REQUEST) { Bitmap thumbnail = (Bitmap) data.getExtras().get("data"); ImageView image = (ImageView) findViewById(R.id.imagePhotoResultView); image.setImageBitmap(thumbnail); Permission yang diperlukan <uses-permission android:name="android.permission.CAMERA" /> <uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera.autofocus" />
9
Mengambil Posisi Permission
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission> // Acquire a reference to the system Location Manager LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); Criteria c=new Criteria(); String provider=locationManager.getBestProvider(c, false); Location location=locationManager.getLastKnownLocation(provider); makeUseOfNewLocation(location); private void makeUseOfNewLocation(Location location) { tampilToast("ada2"); Double longitude = location.getLongitude(); Double latitude = location.getLatitude(); TextView textLat = (TextView) findViewById(R.id.textLat); TextView textLong = (TextView) findViewById(R.id.textLong); textLat.setText(longitude.toString()); textLong.setText(latitude.toString()); }
10
Sekian & Terima Kasih 10
Presentasi serupa
© 2024 SlidePlayer.info Inc.
All rights reserved.