Skip to main content

Posts

Showing posts from 2020

Running Kotlin Program With CommanLine - windows

We can write kotlin programs in text editor and run the programs using command line. We need kotlin complier for this . we can download KOTLIN COMPILER FROM HERE  .  1. Download kotlin-compiler -1.3.72.z.ip 2. Unzip Kotlin compiler to program files in c drive           3. Copy the path of bin (C:\Program Files\kotlin\bin) and add it your to PATH in System variable.    If you do not know how to add path in system variable , you can use the following link Adding PATH in System variable 4. Now open notepad and write your kotlin program fun main(args: Array<String>) { println("Hello World") } 5. save the program as helloworld.kt , i have saved it to my Documents 6. Open cmd  7. I have saved my helloworld.kt file in Documents folder , so i am changing my directory to Documents  (you have to change it to your directory where the file is saved)                 cd documents 8. Compile...

Controlling Back button Behavior in Fragment-- kotlin

when user navigates in an application android maintains back stack of destinations . This allows android to go back to previous destination when user clicks back button . some  times we  need to implement our own back button behavior  for best user experience . For example  if we are in a timer based quiz  application . when the user clicks on the back button if we go back to the previous destination without stopping  the counter , it will crash  the application . So first we need to know whether the  user  pressed the back button accidentally or not by  using a dialogue box . If the user want to go back to previous destination  we need to stop the counter and  then go back to the previous destination. We can control the back button hahavior byusing OnBackPressedDispatcher  . This controls how back button events are dispatched to one or more onBackPressedCallback objects . callbacks are added using addCallback methods. e...

Hiding App bar in a particular fragment with Navigation UI

If you are using navigation UI in your application , if you want to hide your app bar (top bar of your app showing navigation icon)  or back navigation arrow in a particular fragment you can do like this in your Mainactivity class MainActivity : AppCompatActivity() { class MainActivity : AppCompatActivity() { private lateinit var drawerlayout : DrawerLayout private lateinit var navView : NavigationView override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) drawerlayout = findViewById(R.id.drawer_layout) navView = findViewById(R.id.nav_view) val navController : NavController = this.findNavController(R.id.navhost) NavigationUI.setupActionBarWithNavController(this,navController,drawerlayout) NavigationUI.setupWithNavController(navView,navController) navController.addOnDestinationChangedListener { _, destination, _ -> if(d...

Navigation Component Demo With Quizz Application

This is a simple Application demonstrating the use of android navigation component . Screenshots of the apps are The Navigation components consist of Navigation graph , navHost and NavController Navigation graph is an XML file which contains all the information about destinations(destinations are different fragments) and  paths user can take in the app.  Navigation graph of our app is you can download the full source code of this app from my Github https://github.com/arunkfedex/QuizzDemoNavigation Working video of the Application

Hardware information on Windows 10

 To know hardware information in Winows 10  1. Go to control panel and select System and security    2.click on Administrative tools inside System and Security 3.Click on System information in Administrative tools 4.Now you can see your pc's hardware and software information >>> if you want to know more detailed information about your Processor ,Ram ,motherboard it is better to use 3rd party applications like  CPU-Z .  Download   CPUZ   .