Thu. Nov 21st, 2024

activity_main.xml

<?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"
    tools:context=".MainActivity"
    android:orientation='vertical'>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Welcome to implicit exampele"
         />

    
    <Button
        android:id="@+id/opengallary"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Open Gallary" />

</LinearLayout>

MainActivity.kt

package com.androidina.implicit

import android.content.Intent


import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.provider.MediaStore
import android.widget.Button

class MainActivity : AppCompatActivity() {

   
    var btngalary: Button?=null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        
        btngalary=findViewById(R.id.opengallary)

        

        btngalary!!.setOnClickListener {
            var galar=Intent(Intent.ACTION_PICK)
            galar.setType("image/*");
                //galar.setType("video/*");
           // galar.setType("application/pdf");
            startActivity(galar)
        }

    }
}

By Rajashekar

I’m (Rajashekar) a core Android developer with complimenting skills as a web developer from India. I cherish taking up complex problems and turning them into beautiful interfaces. My love for decrypting the logic and structure of coding keeps me pushing towards writing elegant and proficient code, whether it is Android, PHP, Flutter or any other platforms. You would find me involved in cuisines, reading, travelling during my leisure hours.

Leave a Reply

Your email address will not be published. Required fields are marked *