Menus

Wednesday 20 February 2019

How To Make Splash Screen in Android Studio



How to make Splash Screen in your android project.



Steps

Create new project to give application name as SplashScreen


Keeping minimum SDK 


Add on Activity and then finish to open new project.


Then add to EmptyActivity activity in your project.

Select EmptyActivity and give name SplashScreen




For display image copy to drawable folder.

Add to image view in activity_splash.xml file

<?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"    tools:context="com.example.root.splashscreen.SplashActivity">

    <ImageView        
          android:layout_width="match_parent"        
          android:layout_height="match_parent"        
          android:src="@drawable/logo"        />

</RelativeLayout>


Then change theme to select NoTitlebar.


Then go to our main job as three minutes display  splash screen.

Open SplashActivity.java to add this codes

package com.example.root.splashscreen;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class SplashActivity extends AppCompatActivity {

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

        Thread myThread = new Thread(){
            @Override
            public void run() {
                try {
                    sleep(3000);
                    Intent intent = new Intent(getApplicationContext(),MainActivity.class);
                    startActivity(intent);
                    finish();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        };
        myThread.start();


        
    }
}


Then set Splash Screen to start activity.


Go to open manifest file

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="com.example.root.splashscreen">

    <application        android:allowBackup="true"        android:icon="@mipmap/ic_launcher"        android:label="@string/app_name"        android:supportsRtl="true"        android:theme="@style/AppTheme">

        <activity android:name=".SplashActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name=".MainActivity"></activity>
    </application>

</manifest>



Code that hides title bar of activity

  1. requestWindowFeature(Window.FEATURE_NO_TITLE);//will hide the title   
  2. getSupportActionBar().hide(); //hide the title bar  

The setFlags() method of Window class is used to display content in full screen mode. You need to pass theWindowManager.LayoutParams.FLAG_FULLSCREEN constant in the setFlags method.







Sunday 17 February 2019

Show/hide 'div' using JavaScript


Toggle between hiding and showing an element with JavaScript.


Add Html

<span class="label label-success" onclick="showDivtodo();">Show/Hide ToDo</span>
or using button
<button onclick="showDivtodo()">Show/Hide ToDo</button>     
<div  id="todo" style="display:none;">Show/Hide this text</div>
//Your code here..
</div>

Add JavaScript

function showDivtodo(){
      var x = document.getElementById("todo");
      if (x.style.display === "none") {
        x.style.display = "block";
      } else {
        x.style.display = "none";
      }        
    }


JavaScript Toggle (Hide/Show) an Element



Monday 11 February 2019

Yii2 Create span tag in DetailView widget



The span tag is like the div tag. It has no meaning at all and is mostly used for styling by using an id or class


Code Here

[
'attribute' => 'is_status',
        'format' => 'raw',
'value' => (($model->is_status == '1') ? '<span class="label label-success">Active</span>' :      '<span class="label label-danger">Deactive</span>' ),
],


Create url in DetailView widget

           

 [
             'attribute' => 'notice_file_path',
'format' => 'raw',
'value' =>  (!empty($model->notice_file_path) ? Html::a($model->notice_file_path, ['notice-file', 'nid' => $model->notice_id], $htmlOptions=["target"=>"_blank", 'data' => ['method' => 'post',]]) : " - ")
    ],




Saturday 5 January 2019

Replace First Occurrence of String With PHP


using preg_replace.

preg_replace — Perform a regular expression search and replace

mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [,int &$count ]] )


Example

preg_replace('/nothing/', 'something', $str, 1);

Example


<?php

$str="Dear Parent, Fee dues of Mr {V} is {V} on {V}";
echo $str ."<br>";
$c='Shaneesh';
$str= preg_replace("/{V}/", $c, $str, 1);
$str= preg_replace("/{V}/", '2500', $str, 1);
$str= preg_replace("/{V}/", '10-12-2019', $str, 1);
echo $str."<br>";

?>

Output

Dear Parent, Fee dues of Mr {V} is {V} on {V}
Dear Parent, Fee dues of Mr Shaneesh is 2500 on 10-12-2019




Thursday 20 December 2018

Calculating Age from Birthdate


Calculate age from given birthdate


How to Calculate Age from Date of Birth in PHP



<?php

$dateOfBirth = "21-12-1983";
$today = date("Y-m-d");
$diff = date_diff(date_create($dateOfBirth), date_create($today));
echo 'Age is '.$diff->format('%y');

?>




VB6 Code

Function Age (varBirthDate As Variant) As Integer 

 Dim varAge As Variant 

 If IsNull(varBirthdate) then Age = 0: Exit Function 

 varAge = DateDiff("yyyy", varBirthDate, Now) 
 If Date < DateSerial(Year(Now), Month(varBirthDate), _ 
 Day(varBirthDate)) Then 
 varAge = varAge - 1 
 End If 
 Age = CInt(varAge) 

 End Function





Wednesday 19 September 2018

Forcefully Close a Program in Ubuntu


How to close a program from the terminal in ubuntu


  1. The program name with:
    pkill <name_of_program>
    
  2. use of program PID (process id)
    • kill it with kill <PID>

Steps for close program

1. open a Terminal window

2. To view a list of running processes, enter the following text at the prompt and press Enter.
$ ps -A

eg : pkill filezilla   - use program name.


To kill a process using its PID, enter the “killall” command (without the quotes) at the prompt, followed by a space, and then the corresponding PID from the generated list. Press Enter.






Tuesday 19 June 2018

How to play audio and video files in the background on Android


How to set play mx player in the background  on android mobile



Open your mobile


Just launch MX Player app and then press the menu icon at the top-right side of the screen.


Go to choose "Play".    or  (Go to “Settings” and then choose “Player”.)

Check the box next to “Background Play"  


How to enable background play.