Menus

Sunday, 4 October 2020

LAMP install on Ubuntu

 

Install php 7 and apache 2


sudo apt update && upgrade
sudo apt-get install php



Install MySql and phpMyAdmin


sudo apt-get install mysql-server mysql-client
Then install phpmyadmin
sudo apt-get install phpmyadmin -y 


Then check phpmyadmin

The requested URL /phpmyadmin was not found on this server



sudo -H gedit /etc/apache2/apache2.conf

add following line to end of apache config file

Include /etc/phpmyadmin/apache.conf

Then restart apache:

/etc/init.d/apache2 restart
More details - https://askubuntu.com/questions/668734/the-requested-url-phpmyadmin-was-not-found-on-this-server






Solutions for Access Denied For User Localhost on Ubuntu Linux

How to change MySQL 'root' password





 




Friday, 14 August 2020

How to place a YouTube Video in Your android app

 

Hello Friends

    Welcome back to android tutorials in this post we are going to earn about How to place a YouTube Video in Your android app.




Start new project in android studio.

Specify application name

To play Your YouTube video you need to the internet permission for the application

<uses-permission android:name="android.permission.INTERNET"></uses-permission>
Place YouTube video in Your app You need to add YouTube API. Download and add library in Your project.
    YouTube Android API (Click to Download)
    Extract File
    Now open libs folder
    Copy jar files
    Now open android studio 
        Open project view
        Open app folder
        Paste that jar file inside lib folder and right click then click Add As Library

      
To play YouTube video then create YouTube API Key.
    Get the API key to submit application package name and SHA1 certificate fingerprint on google developer console.
        Create new project
        Go to credentials option and create API key
        Copy this API key and to add java class in your android project

Go to Activity, then add Custom View select YouTube Player View and to add a Button text as Play

Then following these code

Config.Java

public class Config {

private static final String YOUTUBE_API_KEY = "Paste Your key....";

public static String getYoutubeApiKey() {
return YOUTUBE_API_KEY;
}

}


MainActivity.Java

import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.google.android.youtube.player.YouTubeBaseActivity;
import com.google.android.youtube.player.YouTubeInitializationResult;
import com.google.android.youtube.player.YouTubePlayer;
import com.google.android.youtube.player.YouTubePlayerView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends YouTubeBaseActivity {


YouTubePlayerView aYouTubePlayerView;
Button btnPlay;
YouTubePlayer.OnInitializedListener mOnInitializedListener;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

btnPlay = (Button) findViewById(R.id.btnPlay);
aYouTubePlayerView = (YouTubePlayerView) findViewById(R.id.youtubeplay);

mOnInitializedListener = new YouTubePlayer.OnInitializedListener() {
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {

//Load video list
/* List<String> videoList = new ArrayList<>();
videoList.add("saIqHKolTHc");
videoList.add("ov8YX9tNyio");
youTubePlayer.loadVideos(videoList); */

//play list
//youTubePlayer.loadPlaylist("PLIFW--Hzc0hbgKs_ZIzMWnElNkHkpsmGP");

//play video
youTubePlayer.loadVideo("saIqHKolTHc");
}

@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {

}
};

btnPlay.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
aYouTubePlayerView.initialize(Config.getYoutubeApiKey(),mOnInitializedListener);
}
});

}
}



Thanks You


  





Wednesday, 24 June 2020

ToWhatsapp privacy policy

Privacy Policy
Logiclab Solutions built the ToWhatsapp app as a Free app. This SERVICE is provided by Logiclab Solutions at no cost and is intended for use as is.
This page is used to inform visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service.
If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect is used for providing and improving the Service. I will not use or share your information with anyone except as described in this Privacy Policy.
The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which is accessible at ToWhatsapp unless otherwise defined in this Privacy Policy.
Information Collection and Use
For a better experience, while using our Service, I may require you to provide us with certain personally identifiable information, including but not limited to Send WhatsApp Messages to People Not in Your Contacts. The information that I request will be retained on your device and is not collected by me in any way.
The app does use third party services that may collect information used to identify you.
Link to privacy policy of third party service providers used by the app
Log Data
I want to inform you that whenever you use my Service, in a case of an error in the app I collect data and information (through third party products) on your phone called Log Data. This Log Data may include information such as your device Internet Protocol (“IP”) address, device name, operating system version, the configuration of the app when utilizing my Service, the time and date of your use of the Service, and other statistics.
Cookies
Cookies are files with a small amount of data that are commonly used as anonymous unique identifiers. These are sent to your browser from the websites that you visit and are stored on your device's internal memory.
This Service does not use these “cookies” explicitly. However, the app may use third party code and libraries that use “cookies” to collect information and improve their services. You have the option to either accept or refuse these cookies and know when a cookie is being sent to your device. If you choose to refuse our cookies, you may not be able to use some portions of this Service.
Service Providers
I may employ third-party companies and individuals due to the following reasons:
  • To facilitate our Service;
  • To provide the Service on our behalf;
  • To perform Service-related services; or
  • To assist us in analyzing how our Service is used.
I want to inform users of this Service that these third parties have access to your Personal Information. The reason is to perform the tasks assigned to them on our behalf. However, they are obligated not to disclose or use the information for any other purpose.
Security
I value your trust in providing us your Personal Information, thus we are striving to use commercially acceptable means of protecting it. But remember that no method of transmission over the internet, or method of electronic storage is 100% secure and reliable, and I cannot guarantee its absolute security.
Links to Other Sites
This Service may contain links to other sites. If you click on a third-party link, you will be directed to that site. Note that these external sites are not operated by me. Therefore, I strongly advise you to review the Privacy Policy of these websites. I have no control over and assume no responsibility for the content, privacy policies, or practices of any third-party sites or services.
Children’s Privacy
These Services do not address anyone under the age of 13. I do not knowingly collect personally identifiable information from children under 13. In the case I discover that a child under 13 has provided me with personal information, I immediately delete this from our servers. If you are a parent or guardian and you are aware that your child has provided us with personal information, please contact me so that I will be able to do necessary actions.
Changes to This Privacy Policy
I may update our Privacy Policy from time to time. Thus, you are advised to review this page periodically for any changes. I will notify you of any changes by posting the new Privacy Policy on this page.
This policy is effective as of 2020-06-24
Contact Us
If you have any questions or suggestions about my Privacy Policy, do not hesitate to contact me at logiclabsolutions@gmail.com.
This privacy policy page was created at privacypolicytemplate.net and modified/generated by App Privacy Policy Generator

Monday, 25 May 2020

Android edit text to show the dd-mm-yyyy date format






Add this code your onTextChanged event.


        EditText date;

        date = (EditText)findViewById(R.id.edtDateofbirth);
        date.addTextChangedListener(new TextWatcher() {
            private String current = "";
            private String ddmmyyyy = "DDMMYYYY";
            private Calendar cal = Calendar.getInstance();


            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                if (!s.toString().equals(current)) {
                    String clean = s.toString().replaceAll("[^\\d.]", "");
                    String cleanC = current.replaceAll("[^\\d.]", "");

                    int cl = clean.length();
                    int sel = cl;
                    for (int i = 2; i <= cl && i < 6; i += 2) {
                        sel++;
                    }
                    //Fix for pressing delete next to a forward slash
                    if (clean.equals(cleanC)) sel--;

                    if (clean.length() < 8){
                        clean = clean + ddmmyyyy.substring(clean.length());
                    }else{
                        //This part makes sure that when we finish entering numbers
                        //the date is correct, fixing it otherwise
                        int day  = Integer.parseInt(clean.substring(0,2));
                        int mon  = Integer.parseInt(clean.substring(2,4));
                        int year = Integer.parseInt(clean.substring(4,8));

                        if(mon > 12) mon = 12;
                        cal.set(Calendar.MONTH, mon-1);

                        year = (year<1900)?1900:(year>2100)?2100:year;
                        cal.set(Calendar.YEAR, year);
                        // ^ first set year for the line below to work correctly
                        //with leap years - otherwise, date e.g. 29/02/2012
                        //would be automatically corrected to 28/02/2012

                        day = (day > cal.getActualMaximum(Calendar.DATE))? cal.getActualMaximum(Calendar.DATE):day;
                        clean = String.format("%02d%02d%02d",day, mon, year);
                    }

                    clean = String.format("%s/%s/%s", clean.substring(0, 2),
                            clean.substring(2, 4),
                            clean.substring(4, 8));

                    sel = sel < 0 ? 0 : sel;
                    current = clean;
                    date.setText(current);
                    date.setSelection(sel < current.length() ? sel : current.length());



                }
            }


            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

            @Override
            public void afterTextChanged(Editable s) {}
        });







Monday, 4 May 2020

How to add custom notification in android app


Create and Display Notification on Android with Example






import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.app.NotificationCompat; import android.view.View; import android.widget.Button; public class NotficationtestActivity extends AppCompatActivity { NotificationCompat.Builder notification; private static final int appuniqueID = 10012; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_notficationtest); notification = new NotificationCompat.Builder(this); notification.setAutoCancel(true); Button btnNotification = (Button) findViewById(R.id.btnNotificationttest); btnNotification.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //Build the notification notification.setSmallIcon(R.drawable.photo); notification.setTicker("Ticker"); notification.setWhen(System.currentTimeMillis()); notification.setContentTitle("TechProgrammingIdeas"); notification.setContentText("Added new video. Subscribe my channel"); Intent intent = new Intent(NotficationtestActivity.this,NotficationtestActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(NotficationtestActivity.this,0,intent,PendingIntent.FLAG_UPDATE_CURRENT); notification.setContentIntent(pendingIntent); //Builds notification and issue it NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); nm.notify(appuniqueID,notification.build()); } }); } }








Thursday, 23 April 2020

Program to add two matrices in C


#include<stdio.h>

void main()
{

int a[10][10],b[10][10],c[10][10];
int i,j,m,n,p,q;

printf("Enter the rows and column of first matrix : ");
scanf("%d%d",&m,&n);

printf("Enter the rows and column of second matrix : ");
scanf("%d%d",&p,&q);

if((m==p) && (n==q))
{

printf("Enter first matrix \n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
 scanf("%d",&a[i][j]);
}
}


printf("Enter second matrix \n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
 scanf("%d",&b[i][j]);
}
}


for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
 c[i][j] = a[i][j] + b[i][j];
}
}


printf("Sum of matrix : \n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
 printf(" %d",c[i][j]);
}
printf("\n");
}


}
else
{
  printf("\nInvalid rows and columns\n");
}

}








Wednesday, 22 April 2020

C program to print two dimensional array





#include<stdio.h>

void main()
{

int a[10][10],i,j,m,n;

printf("Enter size of rows and columns of array : ");
scanf("%d%d",&m,&n);

printf("Enter elements in the array :");

for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
  printf("a[%d][%d] = ",i,j);
  scanf("%d",&a[i][j]);
}
}


printf("Array elements \n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
  printf(" %d",a[i][j]);
}
printf("\n");
}


}




Tuesday, 21 April 2020

C program for add two one dimensional array


#include<stdio.h>

void main()
{

int a[10],b[10],c[10];
int n,i;

printf("Enter the size : ");
scanf("%d",&n);

printf("Enter first array \n");

for(i=0;i<n;i++)
 scanf("%d",&a[i]);

printf("Enter second array \n");

for(i=0;i<n;i++)
 scanf("%d",&b[i]);


for(i=0;i<n;i++)
 c[i]=a[i]+b[i];

printf("Sum of arrays : ");
for(i=0;i<n;i++)
 printf("\n%d",c[i]);


}




Thursday, 2 April 2020

C Program to find largest element in an array

#include<stdio.h>

void main()
{

int arr[100],size,i,max,location;

printf("Enter the number of elements in an array : ");
scanf("%d",&size);

for(i=0;i<size;i++)
{
printf("Enter array value ");
scanf("%d",&arr[i]);
}


max= arr[0];

for(i=1;i<size;i++)
{
if(arr[i]>max)
{
max=arr[i];
location=i+1;
}
}

printf("Maximum element in location %d and its value is %d \n",location,max);


}




Wednesday, 1 April 2020

C Program to reverse the number


#include<stdio.h>

int reversenum(int n)
{

int rev=0,a;

while(n>0)
{
a=n%10;
n=n/10;
rev=rev*10+a;
}

return rev;


}


void main()
{

int n,rev;
printf("Enter the number : ");
scanf("%d",&n);

rev = reversenum(n);

printf("The reverse of the number is %d \n",rev);


}





Check whether a Number is Palindrome or Not - C Program


#include<stdio.h>

void main()
{

int n,m,a,r=0;

printf("Enter the number : ");
scanf("%d",&n);

m=n;

while(n>0)
{
a=n%10;
n=n/10;
r=r*10+a;
}


if(m==r)
 printf("%d is palindrome \n",m);
else
 printf("%d is not palindrome \n",m);

}




Tuesday, 31 March 2020

To check given number is armstrong number or not



#include<stdio.h>

void main()
{

int n,m,b=0,a;

printf("Enter the number ");
scanf("%d",&n);

m=n;

while(n>0)
{

a=n%10;
n=n/10;
b=b+(a*a*a);

}

if(m==b)
  printf("%d is amstrong\n",m);
else
  printf("%d is not amstrong\n",m);


}






Friday, 27 March 2020

Write C program to find factorial of a number


#include<stdio.h>

void main()
{


int n,fact;

printf("Enter the number ");
scanf("%d",&n);

fact=1;

while(n!=0)
{
fact = fact * n;
n--;
}

printf("Factorial of the nmber is %d\n",fact);


}





Thursday, 6 February 2020

Printing Pattern in C



#include<stdio.h>

void main()
{

int l,i,j;

printf("Enter number of lines");
scanf("%d",&l);

for(i=1;i<=l;i++)
{
   for(j=1;j<=i;j++)
   { 
printf(" *");
   }  

   printf("\n");

}

}








Thursday, 30 January 2020

Write c program to print multiplication table of a number


#include<stdio.h>

void main()
{

int n,i;

printf("Enter number ");
scanf("%d",&n);


for(i=1;i<=10;i++)
{

printf("%d * %d = %d\n",i,n,i*n);

}


}





Wednesday, 15 January 2020

Android WebView


Android – How to display information with justify alignment?






Android WebView is used to display web page in android. The web page can be loaded from same application or URL. It is used to display online content in android activity.



WebviewActivity.java 


package com.example.root.shaneeshprograms;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;

public class WebviewActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_webview);

        //create html page
        String htmlPage = "<html><body style=\" text-align:justify\">" +
                "<p style=\"text-align: center; font-size: 30px; \">WebView</p>" +
                "<p style=\" font-size: 22px;  LINE_HEIGHT: 32px;\">"+
                "Android <b>WebView</b> is used to display web page in android. The web page can be loaded from same application or URL. It is used to display online content in android activity."+
                "Android WebView is used to display web page in android. The web page can be loaded from same application or URL. It is used to display online content in android activity."+
                "Android WebView is used to display web page in android. The web page can be loaded from same application or URL. It is used to display online content in android activity."+
                "</p>"+
                "<body></html>";



        //add to webview
        WebView webView = (WebView) findViewById(R.id.webView);
        webView.loadData(htmlPage,"text/html","utf-8");


    }

}



activity_webview.xml


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.root.shaneeshprograms.WebviewActivity">


    <WebView
        android:id="@+id/webView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"></WebView>

</RelativeLayout>



How to load a webpage in android activity





Java code


WebView webView = (WebView)findViewById(R.id.webView);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl("http://yii2ideas.blogspot.com/p/blog-page.html");

xml code

<WebView
    android:id="@+id/webView"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
</WebView>