BLP 4216 MOBİL UYGULAMA GELİŞTİRME-2

Slides:



Advertisements
Similar presentations
Getting Started with Android APIs Ivan Wong. Motivation - “Datasheet” - Recently exposed to what’s available in Android - So let’s see what API’s are.
Advertisements

Package org.androidtown.database.query; import android.app.Activity; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase;
1 Announcements Homework #2 due Feb 7 at 1:30pm Submit the entire Eclipse project in Blackboard Please fill out the when2meets when your Project Manager.
1/29/ Android Programming: FrameLayout By Dr. Ramji M. Makwana Professor and Head, Computer Engineering Department A.D. Patel.
Android - Broadcast Receivers
로봇을 조종하자 3/4 UNIT 17 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 스마트 폰의 센서를 사용할 수 있다. 2.
로봇 모니터링 1/2 UNIT 20 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Message Queue Handler 2.
Mobile Device Development Camera and Sensors Dr.YingLiang Ma.
Applications with Multiple Activities. Most applications will have more than one activity. The main activity is started when the application is started.
로봇을 조종하자 4/4 UNIT 18 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Intent Activity 호출 2.
Android Alert Dialog. Alert Dialog Place Button to open the dialog. public class MainActivity extends ActionBarActivity { private static Button button_sbm;
Google map v2.
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
Mobile Software Development for Android - I397
Lab7 – Appendix.
Lecture 3 Zablon Ochomo Android Layouts Lecture 3 Zablon Ochomo
Android N Amanquah.
several communicating screens
CS240: Advanced Programming Concepts
GUI Programming Fundamentals
Android dan database 2 M. Taufiq, M. Kom.
Android Widgets 1 7 August 2018
Android – Read/Write to External Storage
Android Introduction Camera.
Mobile Device Development
Picasso Revisted.
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CS323 Android Model-View-Controller Architecture
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Android Sensor Programming
CMPE419 Mobile Application Development
CIS 470 Mobile App Development
CA16R405 - Mobile Application Development (Theory)
Many thanks to Jun Bum Lim for his help with this tutorial.
CMPE419 Mobile Application Development
CMPE419 Mobile Application Development
BMI Android Application will take weight and height from the users to calculate Body Mass Index (BMI) with the information, whether user is underweight,
Activities and Intents
CIS 470 Mobile App Development
CIS 493/EEC 492 Android Sensor Programming
CIS 493/EEC 492 Android Sensor Programming
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CMPE419 Mobile Application Development
Adding Components to Activity
CMPE419 Mobile Application Development
CMPE419 Mobile Application Development
CMPE419 Mobile Application Development
Chapter 5 Your Second Activity.
Android Play YouTuBe 建國科技大學 資管系 饒瑞佶 2017/10 V1.
Lasalle-App Tecnología Móvil.
Mobile Programming Broadcast Receivers.
Android Sensor Programming
Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

BLP 4216 MOBİL UYGULAMA GELİŞTİRME-2 Dr. Aslı Ergün 1

BMI Ornek 27.05.2019

<. xml version="1. 0" encoding="utf-8" <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#E1C58E" tools:context=".MainActivity"> <LinearLayout android:layout_height="wrap_content" android:orientation="vertical" android:layout_marginTop="80dp"> <TextView android:id="@+id/tv_baslik" android:layout_width="wrap_content" android:text="BMI HESAPLAMA" android:textSize="24sp" android:textStyle="bold" android:layout_gravity="center" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_marginTop="30dp"> <TextView android:id="@+id/textview4" android:layout_width="50dp" android:layout_marginStart="30dp" android:text="@string/kilo" /> <EditText android:id="@+id/kilo" android:hint="Kilo" android:inputType="number" app:layout_constraintStart_toEndOf="@+id/textview4" /> </LinearLayout> 27.05.2019

<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:id="@+id/textView" android:layout_width="50dp" android:text="@string/boy" android:layout_marginStart="30dp" /> <EditText android:id="@+id/boy" android:hint="Boy" android:inputType="number" app:layout_constraintStart_toEndOf="@id/textView" </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:id="@+id/textView2" android:layout_width="50dp" android:text="@string/yas" android:layout_marginStart="30dp" /> <EditText android:id="@+id/yas" android:hint="Yaş" android:inputType="number" app:layout_constraintStart_toEndOf="@id/textView2" </LinearLayout> 27.05.2019

<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <RadioGroup android:id="@+id/rdgroup" android:layout_width="wrap_content" android:orientation="horizontal" android:layout_marginTop="30dp" android:layout_gravity="center"> <RadioButton android:id="@+id/kadin" android:text="Kadın" /> <RadioButton android:id="@+id/erkek" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="30dp" android:text="Erkek" /> </RadioGroup> <Button android:id="@+id/button" android:layout_marginTop="30dp" android:layout_gravity="center" android:text="HESAPLA" <TextView android:id="@+id/ideal" android:text="@string/BMI" </LinearLayout> 27.05.2019

Mainactivity.java public class MainActivity extends AppCompatActivity { Button butonhesap; TextView tv_ideal; EditText kilo; EditText boy; EditText yas; RadioGroup rdgrup; RadioButton k; RadioButton e; float katsayi; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); kilo = findViewById(R.id.kilo); boy = findViewById(R.id.boy); yas = findViewById(R.id.yas); tv_ideal = findViewById(R.id.ideal); rdgrup = findViewById(R.id.rdgroup); k = findViewById(R.id.kadin); e = findViewById(R.id.erkek); butonhesap = findViewById(R.id.button); butonhesap.setOnClickListener(new View.OnClickListener() { 27.05.2019

Mainactivity.java 27.05.2019 @Override public void onClick(View view) { int secilenRadio= rdgrup.getCheckedRadioButtonId(); switch(secilenRadio) { case(R.id.kadin): katsayi =0.8f; break; case(R.id.erkek): katsayi =0.9f; default: Toast.makeText(MainActivity.this, "Secim yapılmalı", Toast.LENGTH_SHORT).show(); } float b = Float.parseFloat(boy.getText().toString()); float y =Float.parseFloat(yas.getText().toString()); float k =Float.parseFloat(kilo.getText().toString()); float ideal = (b - 100 + y / 10) * katsayi; tv_ideal.setText(Float.toString(ideal)); if (ideal<k) Toast.makeText(MainActivity.this, "Kilolu", Toast.LENGTH_LONG).show(); else if(ideal>k) Toast.makeText(MainActivity.this, "Zayıf", Toast.LENGTH_LONG).show(); else Toast.makeText(MainActivity.this, "Normal", Toast.LENGTH_LONG).show(); }); 27.05.2019

Camera App 27.05.2019

Activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:layout_margin="20dp" tools:context=".MainActivity"> <LinearLayout android:layout_height="wrap_content" android:orientation="vertical"> <VideoView android:id="@+id/videoView" android:layout_height="150dp" /> <ImageView android:id="@+id/imageView" android:layout_marginTop="20dp" app:srcCompat="@android:drawable/ic_menu_camera" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:id="@+id/videocek" android:layout_width="150dp" android:layout_height="60dp" android:text="Video Çek" android:layout_gravity="center" app:layout_constraintEnd_toEndOf="parent" android:layout_margin="20dp" /> android:id="@+id/fotocek" android:text="Fotograf Cek" </LinearLayout> 27.05.2019

AndroidManifest.xml <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.myapplication19"> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> 27.05.2019

MainActivity.java public class MainActivity extends AppCompatActivity { Button fotografcek; Button videocek; private static final int VIDEO_ACTION_CODE = 101; private static final int IMAGE_ACTION_CODE = 102; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); fotografcek = findViewById(R.id.fotocek); videocek = findViewById(R.id.videocek); fotografcek.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { takePhoto(); } }); videocek.setOnClickListener(new View.OnClickListener() { recordVideo(); public void takePhoto() { Intent fotointent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(fotointent, IMAGE_ACTION_CODE); } public void recordVideo() { Intent videointent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); startActivityForResult(videointent, VIDEO_ACTION_CODE); @Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != RESULT_OK) return; switch (requestCode) { case VIDEO_ACTION_CODE: VideoView videoV = findViewById(R.id.videoView); videoV.setVideoURI(data.getData()); videoV.setMediaController(new MediaController(this)); videoV.requestFocus(); videoV.start(); break; case IMAGE_ACTION_CODE: Bundle extras = data.getExtras(); ImageView img = findViewById(R.id.imageView); img.setImageBitmap((Bitmap) extras.get("data")); default: } }