Using String Variable with Kotlin Programming Language |Part-2|

String Variable with Kotlin

Greetings!

Hello Everyone here, Creating another video to demonstrate how to use String Variables in Android Studio using Kotlin Programming language.



 

Environment

Software: Android Studio
Programming Language: Kotlin

Summary

Its a beginner example and Part two of my Kotlin Programming Guide.

To declare any variable in Kotlin, you can simply use two keywords.

Var and Val

First, we are going to use Var Variables is the General variable that can be changed anytime throughout the Kotlin programming.

However, the Val variables are the constraint variables and can be declared only once.

Practice tasks

1. Open Android Studio and go to your project > Java > <com.folder> and edit the Kotlin file to create the variable:

fun main()
{
var name = "James"
val lname = "McDonald"
println(name)
println(lname)
}

Result: Run the compilation and see what happens, Check for error and update it here in comments.

2. Try to reassign a new value to the "var" variable name and the "val" variable lname and see if we can change the value at the later point during our program.

Result: Share the error, if any.

3.  Assign null values to the variables and check out for the outcome. Check for error.
Assign null String declaration to the available by using

:String? Next to the variable name.

Result: Share the error, if any.

We can also assign variables outside the function as well using this method variable will be easily accessible to the other Functions throughout the program.

While declaring the string variable, you may think about how the program decides what kind of variable it. Kotlin chooses the type of variable with very first user input. Like when you mentioned string value to the variable with the quotes that time it assigned, they string type to the variable, and that variable name will remain String Variable throughout the program.
Similarly, if we are going to assign Integer or Float value to the variable for the very first time, it will take is as the Float/Integer variable. We will discuss other types of variables in another post in more detail.

Kotlin - Control Statements |Part - 3|

Control Statements Part-3

In Kotlin Programming language, the Control Statements are similar as in most of the programing language.
Control Statements are the conditional statements that let us create a set of options to make a decision to produce the choice of output if a different type of input supplied to the program.




The Conditional Statements are 
  • if Statement
  • if-else Statement
  • if-else as expression
  • when Statement

if Statement: 

In an, if Statement, program checks for the Condition to match with the given option if matches then perform the activity following it

Syntax

if(<condition>)

{
    <Set of activity>
}

Example 1:

val name: String? = "James"
val lname = "McDonald"
var newVar: String? = null 
 
fun main()
{
if (name == "James")newVar = "Yes the name is " + name 
println(newVar)
}

Example 2:

var newVar: String? = null
var y = 20 
var x = 10
 
fun main() {
if (x > y) newVar = "x is greater number " + x
if (x < y) newVar = "Y is greater number " + y
println(newVar)
}


if-else Statement:

In an if-else statement, program checks for the Condition to match with the given option if matches then perform the activity follows it, if not matches the Condition, then conducts the other event.  

The syntax used for if the Statement is as below: 

if(<condition>) <Set of activity>
else <set of activity>

Example 1:

var newVar: String? = null
var y = 20 
var x = 10
 
fun main()
{
if (x > y) newVar = "x is greater number " + y
else newVar = "Y is greater number " + y
println(newVar)
}

Example2:

val name: String? = "James"
val lname = "McDonald"
var newVar: String? = null
fun main()
{
    if (name == "James")newVar = "Yes it is " + name
    else newVar == "No it is the Something else"

println(newVar)
}

if-else Statement as an expression:

In an if-else statement, it is just like the usual if-else Statement, but in this one, we use curly braces to supply multiple expressions instead of a single line of expression.

Syntax:

if(<condition>)
{
    <Set of activity>
}
else{
    <Set of activity>
}

Example 1:

val name: String? = "James" 
val lname = "McDonald"
var newVar: String? = null
fun main() { if (name == "James") { newVar = "Yes it is " + nameprintln(newVar) } else { newVar == "No it is the Something else"println(newVar) } }

Example 2:

var newVar: String? = null
var y = 20 
var x = 10
fun main() {
 
if (x > y)
{
newVar = "x is greater number " + y 
println(newVar)
}
 
else
{
newVar = "Y is greater number " + y 
println(newVar)
}
}

when Statement:

In a when Statement, program checks for the Condition to match with the multiple options to make a choice, when it matches one of the options, then it performs the activity following the decision.  

Syntax:

when(<variable>)
{
    <variable condition> -> <output>
    <variable condition> -> <output>
    <variable condition> -> <output>
    <variable condition> -> <output>
    else -> <output>
}

Example:

fun main() {
    when(x)
    {
        1 -> println("You selected  1")
        2 -> println("You selected  2")
        3 -> println("You selected  3")
        4 -> println("You selected  4")
        else -> println("Invalid range outside 1 to 4")
    }
}

Kotlin Program "Hello World" codded using Android Studio |Part-1|

Kotlin- Part 1

Introduction: 

 This article describes how to compline Kotlin programming inside the Android Studio for beginners tutorial.

Environment:

OS: Windows 10
Application: Android Studio

Description:

Kotlin is an alternative JVM programing language to create Android Application.

Most of the learners start learning Kotlin with IntelliJ and later start to work on Android Studio.

However, the learners can, from the beginning, learn this on Android studio.

In a small series of tutorials on Kotlin Programming, we introduced the tutorial to do a Kotlin Programming directly on Android Studio. In Part-1, we have a quick demonstration of running a "Hello World" program in the Android Studio application.

Kotlin Programming using Android Studio:




We welcome all our viewers to watch the video of the easy to use Kotlin programming to print "Hello World" into the Android Studio Terminal.

Some related questions:


What is IntelliJ?
Answer: IntelliJ is an Integrated Development Environment(IDE) software written in Java for making software. It was developed by Jetbrains(formally known as IntelliJ) in 2001 to Develop Java-based software with more sophistication; to learn more about IntelliJ history, please visit the Wiki link for IntelliJ.
What is Android Studio?

Android Studio is another IDE that is based upon IntelliJ and is specifically designed to create Android-based applications.
Wiki link to Android Studio.

What is Kotlin?

Java is a language that we still use to create as a preferred language to make Android applications. However, Jetbrains developed the programming language as an alternative to Java named it as Kotline, a new language buddle with more sophistication, ease, and it supports multiple platforms.
Wiki Link to Kotlin

 

How to watch movies from Video Hosting Websites on Android TV?

Unable to play Video from Video Hosting Sites on Android TV.

Environment

Platform: Smart Television
Operating System: Android TV, any version. 

Problem

Unable to play videos from video hosting websites on android TV because you don't have any TV app for the video hosting website.

For Example Unable to play video from YouTube.com without installing its app.
Summary


Some video hosting sites don't have dedicated apps for Android TVs, luckily Youtube has apps for Android TV but it is not the same case for another website.
So, what to do for such hosting sites?

Here in this tutorial, we are going to share an easy trick to get through this trouble.

Reason

Why are we not able to play Video directly from the website?
 
The Browsers on the TV are not capable of playing Video Contents. I tried the Puffin browser, which is available on TV's Playstore, and also tried the Native Browser available with Sony Bravia TV, but both of them are not able to run the playback content. 

Workaround

So for such sites which do not have any apps at present for the Android TV, below is the suggested workaround to make it work:


1. Install the Firefox Mozilla Browser on your Android TV from the link: https://github.com/mozilla-mobile/firefox-tv/releases
  1. On the Television, you will not be able to download the Firefox Browser Application Pack APK directly, and this APK is available on the above link from GitHub. To install it, you need to First use your mobile or computer to download this application and save on Google Drive. 
  2. Once downloaded, upload it on the Google Drive folder and remember the location. 
  3. Now on the TV, use the ES File Explorer app and go to Network>Cloud>Google Drive and install the downloaded Firefox APK from here. 
2. The Firefox app for TV is installed, Now open the hosting website.

3. Now enjoy all the videos with Firefox Browser on your Television screen. 

Conclusion


Installing the Firefox TV APK provided the full-fledged browser feature to the Android Television. Whereas earlier, the native browser and the browser options available on Playstore had limited functionality and were unable to play the video contents. 
Firefox TV-Browser Application removed the limitations and provided with a powerpack feature to play Flash Video Contents & also download them. Now we can watch the movies directly from the browser and do not need a unique App to do that.


Related Article: 

How to play AirtelTV on Android Smart TV?

How to use "AirtelTV" on "Android Smart TV"?

Use AirtelTV on Android Television

Image courtesy Airtel Extreme Website
How to use "AirtelTV" on "Sony Bravia Android TV" & other "Android Smart TVs"?
Problem
AirtelTV app is only for mobile, and if I install it on TV by overriding the conditions, then it is getting installed but is visible horizontally. I can not use cursor as the AirtelTV app uses touch input. So installing AirtelTV App on Android TV is not a solution; it needs some workaround to watch Airtel TV app content in another way. 

Summary

The Airtel TV app is only available for mobile devices, but lots of Airtel users who enjoy paid channels and movies on the AirtelTV app want to enjoy AirtelTV on the bigger screen. 
Like I want to see the videos on my big 55 inch TV Sony Bravia.

Environment

Platform: Smart Television
Operating System: Android TV, any version. 

Workaround

As we know that the Airtel TV app is not present for the Android TV below is the workaround I can suggest to make it work:


1. Install the Firefox Mozilla Browser on your Android TV from the link: https://github.com/mozilla-mobile/firefox-tv/releases
  1. On your TV, you will not be able to download the APK directly, and this APK is available on the above link. To install it, you need to First use your mobile to download this application. 
  2. Once downloaded, save it on your Google Drive Folder. 
  3. Now on your TV, use ES File Explorer>Network>Cloud>Google Drive and install the APK from here. 
2. The Firefox app for TV is installed, Now open the link https://www.airtelxstream.in/

3. Now enjoy all Airtel TV app from here on your TV screen. 

Solution

Identified that Inbuilt Browser and Browser available on TV Playstore cannot download anything from the internet and play the Dynamic Contents like Flash Files and Videos. Puffin Browser and Native browsers are just right for Browsing the Internet.

To check this fact, we first tried to run the https://www.airtelxstream.in/ on the native browser and the Puffin Browser, but it failed to play the Content.
Even those Playstore Browser are not able to download any APK on the TV.
So we installed the Firefox TV APK from Google Drive and then test the https://www.airtelxstream.in/ website on it and found it working without any problem.

Airtel's website is platform-independent and can be used on a computer, mobile, or Smart TV; you can now definitely enjoy the contents of Airtel TV app on https://www.airtelxstream.in/.

Conclusion:

The Firefox Browser is very smart and able to play the Flash & Video contents without any problem.
Using this browser, it is possible to play contents directly from Youtube, Dailymotion, or any other video hosting websites. Now you don't need to keep on installing different applications for watching different Contents. 
For Android TVs, the Firefox Browser is the best because it can add a lot more capabilities than the TV browsers available on Playstore. Now with Firefox, you can not just browse the internet and read Contents but also enjoy additional features like a real mobile or desktop browser, as it let you play music, videos, and download.
Firefox will definitely save you from searching for unnecessary applications and perform most of the Content from one single browser.


Related Articles: 

How to watch movies from https://nites.tv/ on Android TV?


Enter your email address:

Delivered by FeedBurner