Whats the real meaning of 143

Whats the real meaning of 143

143 hmmm…. In numerical terms it is a three digit number, at the hundreds place is 1 and tens place is 4 and at the units place is 3 this is what I taught to my kid who is in grade 2…
For a guy proposing a girl it is 143 or I love you and if the girl doesn't like it is I Hate you….
Then one more I remembered now is I Like you , ‘ I Miss You’…

143 in General as in India many a people consider it a language of letters..for example those who cannot say ‘I Love You’ directly use 1-4-3.
Then, it goes for the same ‘I Hate You’ , ‘ I Miss You’..etc
It entirely depends upon the connection you’ve with person saying or using it on you or in front of you.

I - 1 letter
Love - 4 letters
You - 3 letters
Even though there can be many words that can be formed in this format like
I kick you
I hate you
I miss you
I kiss you and many other but 143 for I love you is more familiar
Thank you 
How to run one-time setup code before executing any XCTest

How to run one-time setup code before executing any XCTest

How to run one-time setup code before executing any XCTest

One approach

When you try to use dispatch_once anyway, Xcode (>=8) is as always very smart and suggests that you should use lazily initialized globals instead. Of course, the term global tends to have everyone indulge in fear and panic, but you can of course limit their scope by making them private/fileprivate (which does the same for file-level declarations), so you don't pollute your namespace.

Imho, they are actually a pretty nice pattern (still, the dose makes the poison...) that can look like this, for example:

private let _doSomethingOneTimeThatDoesNotReturnAResult: Void = {
    print("This will be done one time. It doesn't return a result.")

private let _doSomethingOneTimeThatDoesReturnAResult: String = {
    print("This will be done one time. It returns a result.")
    return "result"

for i in 0...5 {

This prints:

    This will be done one time. It doesn't return a result.
    This will be done one time. It returns a result.

Side note: Interestingly enough, the private lets are evaluated before the loop even starts, which you can see because if it were not the case, the 0 would have been the very first print. When you comment the loop out, it will still print the first two lines (i.e. evaluate the lets).
However, I guess that this is playground specific behaviour because as stated here and here, globals are normally initialized the first time they are referenced somewhere, thus they shouldn't be evaluated when you comment out the loop.

Model View View-Model (MVVM): Getting Started

Android MVVM 

MVVM stands for ModelViewViewModel.

Model: This app contains data. He cannot speak directly to the scenario. In general, it is recommended to expose the data to the viewmodel by the observables.

View: It represents the UI of any application logic-free application. It observes the viewmodel.

ViewModel: It acts as a link between the model and the view. It is responsible for transforming the data from the model. It provides the data stream to the view. It also uses hooks or callback to update the view. It wants data from the model.

The following flow describes the main MVVM pattern.

Using Retrofit 2.x as REST client - Tutorial 1

Using Retrofit 2.x as REST client - Tutorial 1

1. Retrofit

1.1. What is Retrofit

Retrofit is a REST Client for Java and Android. It makes it relatively easy to retrieve and upload JSON (or other structured data) via a REST based webservice. In Retrofit you configure which converter is used for the data serialization. Typically for JSON you use GSon, but you can add custom converters to process XML or other protocols. Retrofit uses the OkHttp library for HTTP requests.

Add the following dependencies to your build.gradle file.
// retrofit
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'

Create New Java file RetrofitInterface.java

import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;

 * Interface for Retrofit

public interface RetrofitInterface {

    Call<PojoUserLogin> login(@Field("countryCode") String countryCode,
                              @Field("userName") String userName,
                              @Field("fullName") String fullName,
                              @Field("birthDate") String birthDate,
                              @Field("profileUrl") String profileUrl,
                              @Field("loginType") String loginType,
                              @Field("deviceInformation") String deviceInformation);

Create New Java file Common.java  Application in manifest file.

import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;

import io.fabric.sdk.android.Fabric;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class Common extends Application {

    private Context mContext;
    private static RetrofitInterface mRetrofitInterface;

    public void onCreate() {
        Fabric.with(this, new Crashlytics());

        mContext = this;


    public static boolean isInternetConnected(Context context) {
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService
        NetworkInfo activeNetwork = connectivityManager != null ? connectivityManager
                .getActiveNetworkInfo() : null;
        return activeNetwork != null && activeNetwork.isConnectedOrConnecting();

    public static RetrofitInterface getRetroFitInterface(Context mContext) {
        if (mRetrofitInterface == null) {
        return mRetrofitInterface;

    private static void initializeRetrofit(final Context mContext) {
        OkHttpClient.Builder builder = new OkHttpClient().newBuilder();
        builder.readTimeout(Constants.TIMEOUT_SECONDS, TimeUnit.SECONDS);
        builder.connectTimeout(Constants.TIMEOUT_SECONDS, TimeUnit.SECONDS);

        if (BuildConfig.DEBUG) {
            HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        builder.addInterceptor(new Interceptor() {
            public Response intercept(Interceptor.Chain chain) throws IOException {
                Request original = chain.request();
                Request request;
                    request = original.newBuilder()
                            .header(mContext.getString(R.string.android), mContext.getString(R.string.android))
                            .header(mContext.getString(R.string.apiKey), mContext.getString(R.string.testAppKey))
                            .method(original.method(), original.body())
                return chain.proceed(request);

        Retrofit retrofit = new Retrofit.Builder().baseUrl(BuildConfig.BASE_URL)
        mRetrofitInterface = retrofit.create(RetrofitInterface.class);

    public static void setUserData(PojoUserLogin.ResponseData responseData, Context mContext, String mLoginType, String mMobileNumber, String mCountryCode) {

        if (responseData.getPojoSettingModel() != null) {
            new PreferenceDefaultSettings(mContext).setSession(responseData.getPojoSettingModel().getSensitivity(), responseData.getPojoSettingModel().isNotifyCharger() + "",
                    responseData.getPojoSettingModel().isChargerDetection() + "", responseData.getPojoSettingModel().isVibrate() + "",
                    responseData.getPojoSettingModel().isFlash() + "", responseData.getPojoSettingModel().getbAlarmTime(), responseData.getPojoSettingModel().getbDetectionTime(), responseData.getPojoSettingModel().getAlarmTone());
            new PreferenceSettings(mContext).setToneId(responseData.getPojoSettingModel().getAlarmTone());


what about this pattern: 1 2 3 4 8 7 6 5 9 10 11 12 16 15 14 13 without matrix in java

what about this pattern: without matrix in  java 

1 2 3 4  
8 7 6 5  
9 10 11 12  
16 15 14 13

class pattern

    static void printPattern(int n)
int count = 1;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
count = count+3;
count = count+5;
    public static void main(String[] args) 


android architecture or Android software stack

or Android software stack is categorized into five parts:

  1. linux kernel
  2. native libraries (middleware),
  3. Android Runtime
  4. Application Framework
  5. Applications

Let's see the android architecture first.

1) Linux kernel

It is the Android system design in the Android design. The Linux kernel is responsible for device drivers, power management, memory management, device management, and asset acquisition.

2) ancient libraries
The library's first library, such as WebKit, OpenGL, FreeType, SQLite, Media, C runtime library (libc), is at the top of the Linux Lunar Calendar.

The WebKit library is responsible for browser support, SQLite support, font support, FreeType for font support, audio and video formats for media playback.

3) Android Runtime
The main library in the android program and the DVM (Dalvik Virtual Machine) are responsible for running the android application. DVM, like JVM, is optimized for mobile devices. It uses less memory and provides faster performance.

4) Android Framework
There is a android framework on top of libraries and on the top of Android. Android API as an Android API, such as UI (UI), telephony, resources, locations, content providers (data), and bundled administrators. Includes. Enriching the Android application provides you with lots of features and interactions.

5) Applications
There are apps on the top of the Android infrastructure. All apps, such as home, contacts, settings, games and browsers are android configurations that use android launcher and libraries. Android Run and Native Libraries are using linux kernal. 

software requirements specification (SRS)

software requirements specification (SRS)

      Specification of Software Requirements (SRS) is a detailed description of the purpose and environment of the software under development. SRS fully describes what the software will do and how it will be expected.


The purpose of this document is to build an online system to manage flights and passengers to reduce flight management. << Include goals that are applicable to your project >>


This document uses the following conventions. << Include conventions as per your application >>

DB Database
DDB Distributed Database
ER Entity Relationship

This project is a prototype for flight management system and is restricted within college areas. It was implemented under the guidance of college professors. This project is useful for flight management teams as well as for passengers.


The purpose of the online flight management system is to reduce flight management and to create a convenient and easy-to-use application for passengers, trying to buy airline tickets. The system is based on a relational database with its flight management functions and reservation. We will have a database server that supports hundreds of major cities around the world as well as thousands of flights by various airline companies. Above all, we hope to provide a comfortable user experience with the best available pricing.


Basis of database systems by ramez elmarsi and shamkant b.navathe


A distributed database system of the airline stores the following information.

Flight details:
This includes the origin of the flight terminal and destination terminal, including stops between, the number of seats booked / available seats between the two destinations etc.
Customer description:
This includes customer code, name, address and phone number. This information may be used for maintaining customer records for any emergency or for any other type of information.
Reservation description:
This includes customer details, code number, flight number, booking date, travel date.


The main features of the airline database system as shown below entity-relationship model (ER model)


System users should be able to get flight information between two provided cities with the provided date / travel time from the database. A route from city A to city B is a sequence of connecting flights from A to B such that: a) with the most two connecting stops, excluding the city's starting city and destination travel, b) the connection time is between one to two hours. The system supports two types of user privileges, Customer, and Employee. Customers will have access to customer functions, and employees will have access to both customer management and flight management functions. Customer must have the following functions:

Make a new reservation
• A lane
• Back and forth
• Multiple cities
• Flexible Date / time
• Confirmation
Cancel an existing reservation
See his itinerary
The employee must have the following management functions:

• Get all customers with seats available on a given flight.
• Get all the flights for a given airport.
• View the flight schedule.
• Get all the flights that the arrival and departure times are timely / delayed.
• Calculate total sales for a given flight.

• Add / Remove flight
• Add a new airport
• Update fares for flights.
• Add a new flight leg opportunity.
• Update departure / arrival times for flight leg instance.
Each flight has a limited number of available seats. There are a number of flights to leave or come to different cities at different dates and times.


The operating environment for the airline management system is as listed below. << Include details according to your application >>

distributed database
client / server system
Operating system: Windows.
database: sql + databases
platform: vb.net/Java/PHP


The global schema, fragment schema, and allocation scheme.
SQL commands for the above questions / applications
How to generate response for application 1 and 2. Assume they are global queries. Explain how different fragments work together to do this.
Implement the database at least using a centralized database management system.


Let's say that this is a distributed airline management system and is used in the following applications:

A request for reservations / cancellations of a flight from any source at any destination, providing connected flights in case of no direct flight between the specified Source-Destination pair exists.
Calculating the high fliers (most frequently fliers) and calculating the appropriate rewards points for the fliers.
Assuming both transactions are single transactions, we design a distributed geographic database by dispersed in four cities Delhi, Mumbai, Chennai, and Kolkatta as shown in fig. below.


The airline reservation system maintains information about flights, seat classes, personal preferences, prices, and bookings. Of course, this project has a high priority because it is very difficult to travel to countries without prior reservations.

Find Airline Flights for two Travel Cities
Displays a detailed list of available flights and make "Reservation" or Book a ticket on a particular flight.
Cancel an existing Reservation.

Other system features include:


The provided database indicates that a single application should work well with data that spreads across different databases and connected through a network of communications as shown below.


The term client / server mainly refers to an architectural or logical division of responsibilities, the client is the application (also known as front-end), and the server is the DBMS (also known as back-end).

A client / server system is a distributed system where,

Some sites are client sites and others are server sites.
All data is located on server sites.
All applications execute on client sites.


Front-end software: Vb.net version
Back-end software: SQL +

4.2 hardware INTERFACES

A browser that supports CGI, HTML and Javascript.


The following are the software used for online flight management management. << Include software details as per your project >>

Software usedDescription
Operating systemWe have chosen Windows operating system for its best support and user-friendliness.
DatabaseTo save the flight records, passengers records we have chosen SQL+ database.
VB.NetTo implement the project we have chosen Vb.Net language for its more interactive support.

This project supports all kinds of web browsers. We use simple electronic forms for reservation forms, ticket reservations etc.


The steps involved to carry out the implementation of the airline database are as listed below.


The E-R Diagram generates a technique for representing the logical structure of a database in a pictorial way. After this analysis is used to sort the data as a relation, normalizing the relationship and finally getting a database of relevance.

ENTITIES: Which distinguish real-world objects in an application.
REQUIREMENTS / REQUIREMENTS: Which define the characteristics of an entity and relationships.
RELATIONSHIP: Which entities connect and represent significant dependencies between them.


The primary purpose of normalization is to reduce the redundancy which means that information should be stored only once. Information storage several times leads to waste storage space and increase in total data size stored.

If a database is not properly designed it can increase with anomalous change. Changing anomalies will appear when the data is added to, modified or deleted from a database table. Similarly, in traditional databases as well as improperly designed relational databases, data redundancy can be a problem. These can be removed by normalizing a database.

Normalisation is the process of collapse of a table into smaller tables. So that each table is related to a single theme. There are three different types of anomaly changes and consists of the first, second and third normal forms (3NF) being considered sufficient for most practical purposes. It should be considered only after careful analysis and complete understanding of its implications.


If there is extensive damage to a large portion of the database due to failure of failure, such as a disk crash, the recovery method returns a previous copy of the database that is backed up to archival storage (usually tape ) and reconstructs a more current state by reapply or reduces the operations of the assigned transactions from backed up logs, to the time of failure.


Security systems require database storage like many other applications. However, special security requirements in the market means that vendors should choose their database partner carefully.


REQUIREMENTS: The flight must be available at the specified date and specified time many customers are making advance reservations.
KATARUNGANG: The flight must reach the start of the right starting terminal and must reach the correct destination.
MAINTAINABILITY: Administrators and flight chargers must maintain proper flight schedules.
USABILITY: Flight schedules should satisfy a maximum number of customer needs.

firebase push notification android example

firebase push notification android example 

In recent times, Google moved from Google Cloud Messaging (GCM) to Firebase Cloud Messaging (FCM). Just like GCM, FCM is a cross-platform messaging solution that allows you to send messages. FCM is completely free and there are no limitations.
If you have followed any of my previous tutorials about GCM, I strongly recommend you migrate to Firebase today itself. In this article we learn the features of firebase cloud messaging by building a simple app. We’ll also learn how to integrate firebase to your backend, so that you can send the messages from your server.


<uses-permission android:name="android.permission.INTERNET"/>
<service android:name=".firebase.FireIDService">
        <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
<service android:name=".firebase.FireMsgService">
        <action android:name="com.google.firebase.MESSAGING_EVENT" />

build.gradle Project

classpath 'com.google.gms:google-services:3.1.0'

build.gradle App

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
compile 'com.google.firebase:firebase-messaging:11.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
apply plugin: 'com.google.gms.google-services'

import android.util.Log;

import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdService;

public class FireIDService extends FirebaseInstanceIdService {
    @Override    public void onTokenRefresh() {
        String tkn = FirebaseInstanceId.getInstance().getToken();
        Log.d("Device Token","Token ["+tkn+"]");


import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.util.Log;

import com.firebasedemo.activity.MainActivity;
import com.firebasedemo.R;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

/** * Created by Rid's Patel on 22-04-2018. */
public class FireMsgService extends FirebaseMessagingService {

    @Override    public void onMessageReceived(RemoteMessage remoteMessage) {

        Log.d("Msg", "Message received ["+remoteMessage+"]");

        // Create Notification        Intent intent = new Intent(this, MainActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 1410,
                intent, PendingIntent.FLAG_ONE_SHOT);

        NotificationCompat.Builder notificationBuilder = new                NotificationCompat.Builder(this)

        NotificationManager notificationManager =

        notificationManager.notify(1410, notificationBuilder.build());

How to download file in url Android 8 Oreo

How to download file in URL Android 8 Oreo.

new DownloadFileFromURL(position).execute(data.get(url));

private class DownloadFileFromURL extends AsyncTask<String, String, String> {
    private ProgressDialog p;
    private int pos = 0;

    public DownloadFileFromURL(int p) {
        pos = p;

    @Override    protected void onPreExecute() {
        p = new ProgressDialog(context);
        p.setMessage("Downloading 0%");

    @Override    protected void onProgressUpdate(String... values) {
        p.setMessage("Downloading " + values[0] + "%");

    @Override    protected String doInBackground(String... f_url) {
        int count;
        String filename = f_url[0];
        String[] parts = filename.split("/");
        String part2 = parts[parts.length - 1];
        Boolean isSDPresent = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
        File myNewFolder = null;
        if (isSDPresent) {
            String newFolder = "/patelwala";
            String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
            myNewFolder = new File(extStorageDirectory + newFolder);
            if (myNewFolder.exists()) {
            } else {
        } else {
            String newFolder = "patelwala";
            myNewFolder = context.getDir(newFolder, Context.MODE_PRIVATE);
            if (!myNewFolder.exists()) {
        try {
            URL url = new URL(f_url[0]);

            URLConnection conection = url.openConnection();
            // getting file length            int lenghtOfFile = conection.getContentLength();
            // input stream to read file - with 8k buffer            InputStream input = new BufferedInputStream(url.openStream(), 8192);
            // Output stream to write file            OutputStream output = new FileOutputStream(myNewFolder + "/" + part2);
            byte data[] = new byte[1024];

            long total = 0;
            while ((count = input.read(data)) != -1) {
                //if (!Webservice.isCancelled) {                total += count;

                // writing data to file                publishProgress("" + (int) ((total * 100) / lenghtOfFile));
                output.write(data, 0, count);
              /*  } else {                    break;                }*/
            // flushing output            output.flush();
            // closing streams            output.close();

        } catch (Exception e) {
            Log.e("Error: ", e.getMessage());

        return myNewFolder + "/" + part2;

    /**     * After completing background task     **/    @Override    protected void onPostExecute(String s) {


public void openDocument(String name) {
    if (co == 0) {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        File file = new File(name);
        String extension = android.webkit.MimeTypeMap.getFileExtensionFromUrl(Uri.fromFile(file).toString());
        String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
        if (extension.equalsIgnoreCase("") || mimetype == null) {
            // if there is no extension or there is no definite mimetype, still try to open the file            intent.setDataAndType(Uri.fromFile(file), "text*//*");
        } else {
            intent.setDataAndType(Uri.fromFile(file), mimetype);
        // custom_alert_dialog message for the intent        context.startActivity(Intent.createChooser(intent, "Choose an Application:"));
    } else {
        co = 0;

        File f = new File(name);
        Uri uri = Uri.parse("file://" + f.getAbsolutePath());
        Intent share = new Intent(Intent.ACTION_SEND);
        //  share.putExtra(Intent.EXTRA_STREAM, uri);        String extension = android.webkit.MimeTypeMap.getFileExtensionFromUrl(Uri.fromFile(f).toString());
        String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
        if (extension.equalsIgnoreCase("") || mimetype == null) {
            // if there is no extension or there is no definite mimetype, still try to open the file            share.setType("text*//*");
        } else {
        share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
        context.startActivity(Intent.createChooser(share, "Share File"));