How to create android app for website.?How to open website in android app

activity_main.xml

Just add webView to xml


Main Activity.Java

 import android.os.Bundle;  
 import android.support.annotation.Nullable;  
 import android.support.v7.app.AppCompatActivity;  
 import android.webkit.WebView;  
 import android.webkit.WebViewClient;  
 public class MainActivity extends AppCompatActivity {  
   private WebView mywebView;  
   String url="www.google.com";  
   @Override  
   protected void onCreate(@Nullable Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
     setContentView(R.layout.activity_main);  
     mywebView=findViewById(R.id.web);  
     mywebView.getSettings().setJavaScriptEnabled(true);  
     mywebView.getSettings().setSupportZoom(true);  
     mywebView.getSettings().setUseWideViewPort(true);  
     mywebView.getSettings().setLoadWithOverviewMode(true);  
     mywebView.loadUrl(url);  
     mywebView.setWebViewClient(new WebViewClient());  
   }  
   @Override  
   public void onBackPressed() {  
     if(mywebView.canGoBack()) {  
       mywebView.goBack();  
     } else {  
       super.onBackPressed();  
     }  
   }  
 }  


Why my android app is not working.? Why my android app crashes.?

Hello friends,

Here I am going to discuss what are the general and mistakes people do or they forget while making an android app.

Reason app do not open or crashes in between

1.Do not include permission in Android.manifest

2.Do not add activity in Android.manifest

3.xml file id to element is not mapped or connect to UI

4.Calling of a function that goes into a loop

5.Calling of a function directly in onCreate()

6.Xml file is not connected

There are many others error due to minor mistakes.

Try to avoid all these silly mistakes.

How to clear screen in cmd in windows.?

It's very simple one line command in cmd just run

 cls  



How to make caluculator app using android.?

activity_main.xml

 <?xml version="1.0" encoding="utf-8"?>  
 <android.support.constraint.ConstraintLayout  
   xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"  
   android:layout_height="match_parent">  
   <LinearLayout  
     android:layout_width="match_parent"  
     android:layout_height="match_parent"  
     android:orientation="vertical" >  
     <LinearLayout  
       android:layout_width="match_parent"  
       android:layout_height="wrap_content" >  
       <TextView  
         android:id="@+id/textView1"  
         android:layout_width="wrap_content"  
         android:layout_height="wrap_content"  
         android:text="Value 1"  
         android:textAppearance="?android:attr/textAppearanceLarge" />  
       <EditText  
         android:id="@+id/editText1"  
         android:layout_width="wrap_content"  
         android:layout_height="wrap_content"  
         android:layout_weight="1"  
         android:ems="10"  
         android:inputType="number" >  
         <requestFocus />  
       </EditText>  
     </LinearLayout>  
     <LinearLayout  
       android:layout_width="match_parent"  
       android:layout_height="wrap_content" >  
       <TextView  
         android:id="@+id/textView2"  
         android:layout_width="wrap_content"  
         android:layout_height="wrap_content"  
         android:text="Value2"  
         android:textAppearance="?android:attr/textAppearanceLarge" />  
       <EditText  
         android:id="@+id/editText2"  
         android:layout_width="wrap_content"  
         android:layout_height="wrap_content"  
         android:layout_weight="1"  
         android:ems="10"  
         android:inputType="number" />  
     </LinearLayout>  
     <LinearLayout  
       android:layout_width="match_parent"  
       android:layout_height="wrap_content" >  
       <Button  
         android:id="@+id/button1"  
         android:layout_width="wrap_content"  
         android:layout_height="wrap_content"  
         android:text="+" />  
       <Button  
         android:id="@+id/button2"  
         android:layout_width="wrap_content"  
         android:layout_height="wrap_content"  
         android:text="-" />  
       <Button  
         android:id="@+id/button3"  
         android:layout_width="wrap_content"  
         android:layout_height="wrap_content"  
         android:text="*" />  
       <Button  
         android:id="@+id/button4"  
         android:layout_width="wrap_content"  
         android:layout_height="wrap_content"  
         android:text="/" />  
       <Button  
         android:id="@+id/button5"  
         android:layout_width="wrap_content"  
         android:layout_height="wrap_content"  
         android:text="C" />  
     </LinearLayout>  
     <LinearLayout  
       android:layout_width="match_parent"  
       android:layout_height="wrap_content" >  
       <TextView  
         android:id="@+id/textView3"  
         android:layout_width="wrap_content"  
         android:layout_height="wrap_content"  
         android:text="Result"  
         android:textAppearance="?android:attr/textAppearanceLarge" />  
       <EditText  
         android:id="@+id/editText3"  
         android:layout_width="wrap_content"  
         android:layout_height="wrap_content"  
         android:layout_weight="1"  
         android:ems="10"  
         android:inputType="number" />  
     </LinearLayout>  
   </LinearLayout>  
 </android.support.constraint.ConstraintLayout>  

MainActivity.java

 package com.app.kapil.calculator;  
 import android.os.Bundle;  
 import android.support.v7.app.AppCompatActivity;  
 import android.view.View;  
 import android.widget.Button;  
 import android.widget.EditText;  
 public class MainActivity extends AppCompatActivity {  
   Button b1,b2,b3,b4,b5;  
   EditText t1,t2,t3;  
   @Override  
   protected void onCreate(Bundle savedInstanceState) {  
     super.onCreate(savedInstanceState);  
     setContentView(R.layout.activity_main);  
     b1=(Button) findViewById(R.id.button1);  
     b2=(Button) findViewById(R.id.button2);  
     b3=(Button) findViewById(R.id.button3);  
     b4=(Button) findViewById(R.id.button4);  
     b5=(Button) findViewById(R.id.button5);  
     t1=(EditText) findViewById(R.id.editText1);  
     t2=(EditText) findViewById(R.id.editText2);  
     t3=(EditText) findViewById(R.id.editText3);  
     b1.setOnClickListener(new A());  
     b2.setOnClickListener(new B());  
     b3.setOnClickListener(new C());  
     b4.setOnClickListener(new D());  
     b5.setOnClickListener(new E());  
   }  
   class A implements View.OnClickListener  
   {  
     @Override  
     public void onClick(View arg0) {  
       int a,b,ans;  
       a=Integer.parseInt(t1.getText().toString());  
       b=Integer.parseInt(t2.getText().toString());  
       ans=a+b;  
       t3.setText(""+ans);  
     }  
   }  
   class B implements View.OnClickListener  
   {  
     @Override  
     public void onClick(View arg0) {  
       int a,b,ans;  
       a=Integer.parseInt(t1.getText().toString());  
       b=Integer.parseInt(t2.getText().toString());  
       ans=a-b;  
       t3.setText(""+ans);  
     }  
   }  
   class C implements View.OnClickListener  
   {  
     @Override  
     public void onClick(View arg0) {  
       int a,b,ans;  
       a=Integer.parseInt(t1.getText().toString());  
       b=Integer.parseInt(t2.getText().toString());  
       ans=a*b;  
       t3.setText(""+ans);  
     }  
   }  
   class D implements View.OnClickListener  
   {  
     @Override  
     public void onClick(View arg0) {  
                try{  
                int a,b,ans;  
       a=Integer.parseInt(t1.getText().toString());  
       b=Integer.parseInt(t2.getText().toString());  
                ans=a/b;  
       t3.setText(""+ans);  
                }  
                catch(Exception e){  
        Toast.makeText(MainActivity.this,"Enter a number other than 0 "+e,Toast.LENGTH_LONG).show();  
                }  
     }  
   }  
   class E implements View.OnClickListener  
   {  
     @Override  
     public void onClick(View arg0) {  
       t1.setText("");  
       t2.setText("");  
       t3.setText("");  
       t1.requestFocus();  
     }  
   }  
 }  

Output



















I hope that helps :)

-Kapil Arora-

How to setup android studio.? How to install android studio.? Error in installing android studio.? Windows/Linux/MacOs

Hello friends,

The problem in installing an android studio is very common to all as it's huge setup includes everything in it required to build awesome apps.

Don't worry if it doe not installed in first go we will soon start in your pc and we will look into the issue and fix it.

Basically, you need two things to run the android studio.
  1. Java environment (JDK installed) Download Java
  2. Latest Android Studio(3.2 at this time) Download Android Studio
If you have already downloaded java and installed in your pc then you need to check which java version is installed on  your pc.

How to check which java version is installed.? 
 
For Windows/Linux 
  • Open cmd/terminal
  •  For Windows press window key+R and type cmd and run it.
  • For Linux, search terminal run it 

In both, you can use this command to know your java version installed javac -version

Below is the sample output in windows



For MacOs

Find Java Control Panel on Mac
Launch the Java Control Panel on Mac (10.7.3 and above)
  1. Click on Apple icon on upper left of the screen.
  2. Go to System Preferences
  3. Click on the Java icon to access the Java Control Panel.
 To know in more details for macos click here


Now, we are done with installation of java or checking of java version lets's come back to android studio installation.

It's recommended that you need to connect to wifi or a good internet connection with your system so if any file missing or any updation require it fixes it while installation only.

If you got "Hello World " on the screen in the first go then many congratulations to you as you have successfully running android studio and ready to go.

If there is some errors or red lines on the files don't worry there might be some updation require or SDK file location missing you just connect your system to the internet and start android studio again.
 
And in somecases it might not pick the sdk location automatically and you need to set the SDK path in case it could not pick the path for SDK.

How to set SDK path or How to find SDK location.?  

Your SDK location will be in

 Windows:- C:/user/<your system name>/AppData/Local/Android
Linux:- /home/AccountName/Android/Sdk
Mac:- /Library/Android/Sdk
  •  Ctrl+Alt+S 
  •  File->Setting  
  • Tools->Sdk Manager



I hope that help and worked  :)

-Kapil Arora-






How to click on the link in cmd.? How to click on link to verify Firebase CLI Login.?

Hey,

Once the same problem was with me..

I was deploying my project to firebase and it sends me the link to verify. But I was not able to click the link. After searching a bit I got this.

Follow these simple step

1. Search cmd

2. Right click on command prompt

3. Select run as administrator

4. Now you can start your work and you will be able to click any link and functional things here.

Hope that helps.

Thank you

What is Error of R in android

Hello friend,

This error is because you have something in your java file or xml file whose Resources are not found in the project.

And then

You can Build->Rebuild Project that might help.

How to get full date in format day/month/year OR year/month/day in javascript

Hello friends,

Create a html file paste the following code in <script></script> tag

You have all the items day,date and year. You can concatenate the way you want.




If you have observed month is added +1 that's because in javascript month range is (0-11) and in actual we have 12 months.

Month range(0-11)
Date range(1-31)
Week range(0-6)

How to deploay project to firebase from my pc..? How to host project to firebase using command line from my pc.?


Hello friends, 

It sounds like very tough that how to host project from pc using command like. But in real it's just two step process.

Note:- Command line for windows and are cmd and terminal respectively.

 Before moving ahead you must have installed NodeJS in your pc Download NodeJS. 

If you have done that then use command node -v  in cmd it will you version like v1.0.90.
If you got this that great you are ready to go ahead. 

  •  Step1
    • Login to firebase console
    • Create a project  
  • Step 2
    • Open your project folder in your pc
    • Type cmd in top bar (www->kapilonline->cmd) and enter
    •  You will see a black screen command line interface is prompt
  •  Step 3
    • Use command firebase login
    • Use command firebase deploy




 Bingo!!!! You deployed your project to firebase. 
If  still problem there something missing and not working out for you comment below

How to use firebase for website.? How to use firebase for android.? How to insert data in firebase.?

Hello friends,

The time I am typing this post just 5 min. before I have resolved this or understood this.

So, As you are new to firebase or beginner then you need to know some of basic things.

1.Firebase is not SQL database
2.There is no query to insert data in firebase.
3.Firebase store data in tree structure there are nodes and child nodes.

Steps to follow for easy start
1.Login Firebase
2.Click Go to console
3.Create new project
4.Give any name to project
5.Click setting icon on right of Project overview
6.Choose IOS or ANDROID or Website for which you are using firebase

For website you need to include following sample details in website head section
Note:- your-project-name is here to show you sample details
<head>
<script>
var config = {
    apiKey: "AIzaSyC5V6O48uU3wM2A1eeHzVKW_IfZWrO7X3s",
    authDomain: "your-project-name.firebaseapp.com",
    databaseURL: "https://your-project-name.firebaseio.com",
    projectId: "your-project-name",
    storageBucket: "your-project-name.appspot.com", 
    messagingSenderId: "3186427xxxx"
  };
  firebase.initializeApp(config); 

</script>
</head> 

---------------------------------------------------------------------------

For Android App
Following these steps

Note:-If you are in upgraded version of Android studio then click on "Tools->Firebase->Login->Connect to firebase".




 OR

If  above method does not work for you login firebase in browser and under Console select project
1.Goto project setting 
2.Select android 
3.Copy package name from android project app and paste it to register app
4.Download google-service JSON File 
5.Paste that file under app folder in project folder of your project.







Note:-Now Click on Add Realtime database to your android project to connect your database to your project.


Coming to database and storage

1.Database where information is saved like name email phone etc.

2.Storage where image,pdf,file etc. is stored.

Data will not inserted untill you make following changes

1.Change database cloud beta to real database








2.Under rule section change read and write to true.











Want to know how to host website on firebase for free from your desktop.?
Comment below

Tcs question to print series 1,2,1,3,2,5,3,8...

#include <stdio.h>

int main()
{
     int n,j=2,i,a=1,b=2,c;
     int arr[20];
     scanf("%d",&n);
     arr[0]=a;
     arr[1]=b;
         
         for(i=1;i<=n;i++){
             
             c=b-a;
             arr[j]=c;
             j++;
             a=b;
             b=c;
             
             
             c=b+a;
              arr[j]=c;
             j++;
             a=b;
             b=c;
            
             
         }
     //display series
     
     for(i=0;i<10;i++){
         printf("%d,",arr[i]);
     }
      
}

Tcs question - C program to reverse string using command line

#include <stdio.h>


int main(int argc,char *argv[])

{

    int len;
     char *ptr;//take pointer to traverse
     
    ptr=argv[1];
    
    
    len=strlen(argv[1]);

    if(argc==1){

        printf("Error:Please enter atleast one argument");

        return 0;

    }

        while(len>=0){
            
            printf("%c ",ptr[len--]);
        }



      return 0;

      

     

     

}

Tcs question C program to find LCM in command line

#include <stdio.h>


 int main(int argc, char *argv[])
 {

 int lcm,i,num1,num2,max_value=0;
  num1=atoi(argv[1]);
  num2=atoi(argv[2]);
   
   max_value=(num1>num2)?num1:num2;
   
  while(1){//Always true till we get the lcm
      
       if(max_value%num1==0&&max_value%num2==0){
           
       printf("LCM is :%d",max_value);
       break;
       }
       ++max_value;
  }
  
  

return 0;
}

Tcs question find out gcd of two number in c using command line

#include <stdio.h>


 int main(int argc, char *argv[])
 {

 int gcd,i,num1,num2=0;
  num1=atoi(argv[1]);
  num2=atoi(argv[2]);
   
  
  for(i=1;i<=num1 && i<=num2;i++){
      
      if(num1%i==0 && num2%i==0){
      gcd=i;
          
      }
  }
  printf("GCD is :%d",gcd);

return 0;
}


Tcs question print string in c using command line

#include <stdio.h>

int main(int argc,char *argv[])
{
     
    if(argc==1){
        printf("Error:Please enter atleast one argument");
        return 0;
    }
    
//Note:- argv[0] is by default 0 our input string start storing from argv[1]. So it's better to start for loop from 1

      int i,v=0,size=argc-1;
      
      char *str;//intialize pointer
      
      //allocate memory to which pointer points
      
      str=(char*)malloc(v);//intially zero
      
      //now re allocate memory as per size of input sting arguments
      for(i=1;i<=size;i++){
          
     int length=v+strlen(argv[i]);
      str=(char*)realloc(str,length);
      
      //now concatenate the string argument
      strcat(str,argv[i]);
      //give a namespace
      strcat(str," ");
      }
      
      //now print string use %s not %concatenate
      printf("%s\n",str);
      
      return 0;
      
     
     
}