Mobile Development Articles

Page 33 of 156

How to work with Camera in an Android App using Kotlin?

Azhar
Azhar
Updated on 21-Jul-2020 5K+ Views

This example demonstrates how to work with Camera in an Android App using Kotlin.Step 1 − Create a new project in Android Studio, go to File ? New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.Example Step 3 − Add the following code to src/MainActivity.ktimport android.Manifest import android.content.Intent import android.content.pm.PackageManager import android.graphics.Bitmap import android.os.Bundle import android.provider.MediaStore import android.widget.Button import android.widget.ImageView import androidx.appcompat.app.AppCompatActivity import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat class MainActivity : AppCompatActivity() {    private val cameraRequest = 1888    lateinit var imageView: ImageView    override fun onCreate(savedInstanceState: Bundle?) ...

Read More

How to create animation using XML file in an Android App using Kotlin?

Azhar
Azhar
Updated on 21-Jul-2020 459 Views

This example demonstrates how to create animation using XML files in an Android App using Kotlin.Step 1 − Create a new project in Android Studio, go to File? New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.Example Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.view.View import android.view.animation.Animation import android.view.animation.AnimationUtils import android.widget.Button import android.widget.TextView import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity(), Animation.AnimationListener {    private lateinit var textView: TextView    private lateinit var buttonZoom: Button    private lateinit var buttonBlink: Button   ...

Read More

How to create GridView Layout in an Android App using Kotlin?

Azhar
Azhar
Updated on 21-Jul-2020 3K+ Views

This example demonstrates how to create GridView Layout in an Android App using Kotlin.Step 1 − Create a new project in Android Studio, go to File? New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.Example Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.widget.AdapterView.OnItemClickListener import android.widget.GridView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    lateinit var gridView: GridView    private var playerNames = arrayOf("Cristiano Ronaldo", "Joao Felix", "Bernado Silva", "Andre    Silve", "Bruno    Fernandez", "William Carvalho", "Nelson Semedo", "Pepe", "Rui Patricio") ...

Read More

How to switch between different Activities in Android using Kotlin?

Azhar
Azhar
Updated on 21-Jul-2020 8K+ Views

This example demonstrates how to switch between different Activities in Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File? New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.Example Step 3 − Add the following code to src/MainActivity.ktimport android.content.Intent import android.os.Bundle import android.widget.Button import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"       val button:Button = findViewById(R.id.btnOpenAct2)       button.setOnClickListener ...

Read More

How to create Tab Layout in an Android App using Kotlin?

Azhar
Azhar
Updated on 21-Jul-2020 3K+ Views

This example demonstrates how to create Tab Layout in an Android App using Kotlin.Step 1 − Create a new project in Android Studio, go to File? New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.Example Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import androidx.appcompat.app.AppCompatActivity import androidx.viewpager.widget.ViewPager import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout.OnTabSelectedListener import com.google.android.material.tabs.TabLayout.TabLayoutOnPageChangeListener class MainActivity : AppCompatActivity() {    lateinit var tabLayout: TabLayout    lateinit var viewPager: ViewPager    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)     ...

Read More

How to detect if a user is using an Android tablet or a phone using Kotlin?

Azhar
Azhar
Updated on 21-Jul-2020 843 Views

This example demonstrates how to detect if a user is using an Android tablet or a phone using Kotlin.Step 1 − Create a new project in Android Studio, go to File? New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.Example Step 3 − Add the following code to src/MainActivity.ktimport android.content.Context import android.os.Bundle import android.telephony.TelephonyManager import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import java.util.* class MainActivity : AppCompatActivity() {    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState)       setContentView(R.layout.activity_main)       title = "KotlinApp"   ...

Read More

Why Kotlin will replace Java for Android App Development

AmitDiwan
AmitDiwan
Updated on 13-Jul-2020 300 Views

While working with Kotlin, Java libraries and frameworks can be used. This can be done with the help of advanced frameworks, without having to change the whole project. Java and Kotlin co-exist and can be present in the same project.Kotlin code can be placed inside Android Studio, without making the whole project in Kotlin.It is an open source platform that also helps in quick development of projects. It is easy, and readable, and considerably requires lesser coding in comparison to Java.Kotlin was developed by JetBrains, and IntelliJ is the IDE which Android Studio also uses.Kotlin plugin can be installed and ...

Read More

How to make a GridLayout fit screen size in Android?

Azhar
Azhar
Updated on 09-Jul-2020 2K+ Views

This example demonstrates how How to make a GridLayout fit screen size in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.                                                                 Step 3 − Add the following code to src/MainActivity.javapackage com.app.sample; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.Gravity; import android.widget.GridLayout; import android.widget.ImageView; ...

Read More

How to lay out Views in RelativeLayout programmatically in Android?

Azhar
Azhar
Updated on 09-Jul-2020 940 Views

This example demonstrates how to lay out Views in RelativeLayout programmatically in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javapackage com.app.sample; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.RelativeLayout; import android.widget.RelativeLayout.LayoutParams; import android.widget.Toast; public class MainActivity extends Activity {    RelativeLayout relativelayout;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);     ...

Read More

How to send a SMS using SMSmanager in Dual SIM mobile in Android?

Azhar
Azhar
Updated on 09-Jul-2020 1K+ Views

This example demonstrates how do I send in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.             Step 3 − Add the following code to src/MainActivity.javaimport androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import androidx.core.content.ContextCompat; import android.Manifest; import android.content.pm.PackageManager; import android.os.Bundle; import android.telephony.SmsManager; import android.text.TextUtils; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    Button btnSend;    EditText editTextNum, editTextMsg;    private static final ...

Read More
Showing 321–330 of 1,551 articles
« Prev 1 31 32 33 34 35 156 Next »
Advertisements