Sublime Text 3 Licence Key

Sublime Text 3 Licence Key  

 
Step For Register



1. Click on Help Menu select Enter Licence Key.

2. Copy All Code from below and paste into here.

3. Finaly Click on Submit.

4. Congrats Your Sublime are Registered. ☺☺

<!------ Start Code ------->

TwitterInc
200 User License
EA7E-890007
1D77F72E 390CDD93 4DCBA022 FAF60790
61AA12C0 A37081C5 D0316412 4584D136
94D7F7D4 95BC8C1C 527DA828 560BB037
D1EDDD8C AE7B379F 50C9D69D B35179EF
2FE898C4 8E4277A8 555CE714 E1FB0E43
D5D52613 C3D12E98 BC49967F 7652EED2
9D2D2E61 67610860 6D338B72 5CF95C69
E36B85CC 84991F19 7575D828 470A92AB

<!------ EndCode ------->

Note : Its Copy From Another Location No Our Generated Key
0

HTML5 Tutorial End With JavaScript

HTML5 Tutorial End With JavaScript

html javascript

Topics

  1. HTML with JavaScript
  2. HTML Events
  3. HTML Live Coding

What is JavaScript?

JavaScript Helps to Change Behaviour of Page in Live in front of our eyes we see its changes live in web pages. Like.

  1. Reloading a web page
  2. Redirection
  3. Taking Value From Input Box
  4. Animation
  5. Fetching Live data From Server
  6. Live Chat 
Now i will not Go Details in JavaScripts in this Topic My Aim in this topic is How to Write JavaScript Codes, Html Codes.

But Don’t Worry I will Cover my JavaScript in Seperate Topic.


JavaScript Start with Tag <script>

Code  : <script>JavaScript Codes</script>
Use this Tag Only when You using JS in HTML page if you write external js dont use this tag on that js page.


We link external js file by using


code : <script src=”first.js”></script>
 

This is Our External js file first.js which contain only js Code Seprately like css.
We can use Comments in js by using
(//) single line or multi line (/* comments */) 


E.g 1. Adding Js in Your HTML files and Takes Input From text Box and alert that value in browser.

  



<!DOCTYPE html>
<html>
<head> <title>HTML with JavaScript</title></head>
<input type="text" id="name">
<button onclick="display()">Display</button>
<body>
 <!-- JavaSript begin -->
<script type="text/javascript">
 function display(){

        //declaring js Vaiable 
      var a;
        //storing my html element (DOM Element : Document Object Model)
        //every dom element had its own list of properties 

        //finding My Dom Element with its id
  a=document.getElementById("name");
  
  //Alert Popup Box which Display input value
  alert(a.value);
 }
</script>
<!-- Java Script End -->
</body>
</html>
 
 
Results :
javascript example
After Clicking .

javascript result


E.g 2. Set Value in div and Inpux Box using js

<!DOCTYPE html>
<html>
<head> <title>HTML with JavaScript</title></head>
<input type="text" id="name">
<input type="text" id="copyvalue">
<div id="copydiv"></div>
<button onclick="display()">Display</button>
<body>
 <!-- JavaSript begin -->
<script type="text/javascript">
 function display(){

        //declaring js Vaiable 
      var a;
        //storing my html element (DOM Element : Document Object Model)
        //every dom element had its own list of properties 

        //finding My Dom Element with its id
  a=document.getElementById("name");
  //finding element with id copyvalue and setting value
  document.getElementById('copyvalue').value=a.value;
  //finding element with id copydiv and setting text
  document.getElementById('copydiv').innerHTML=a.value;
  //div dont have propert of (value) it had property of text 
 }
</script>
<!-- Java Script End -->
</body>
</html>

Result : 

js example
 After Clicking


js example


I know You All think What is Events in HTML?
Events in HTML just like some action taken by user like.
  1. Clicking a Button
  2. Moving Mouse
  3. Keypress (when user press key from keyboard)
  4. Keyup (when user move finger from keyboard)
  5. By using This Events We Can Call Our JavaScript See previous Example
  6. (Button Click) 
Video Tutorial


Source Codes : Download
0

HTML Tutorial Topic 4

HTML Tutorial Topic 4

html forms

Welcome Again all,
Today I am Going To Start New Topic
Very Very Important as a Web Developer
For HTML which covers Forms.
Let’s Start...

Topics

  1. Form Elements select and Text Area
  2. Input Elements
  3. Input Elements Attributes
Form elements are such element which we used for creating our HTML form like Some Elements input box,dropdown select,Buttons,Textarea.
Input Box – For Simple input of data in any format.
Select Dropdown – For Selecting Item in a list of items
textarea – For Large Area of Input Contents ,Description Message which is  used to display our data in also multiline.
Button – For Submit our Form or Simple Button For Any Events.

List of Form Elements.

  1. <form>
  2. <select>
  3. <input>
  4. <textarea>
  5. <button>
  6. <option>
  7. <datalist>
  8. <optgroup>
  9. <button> 


<!DOCTYPE html>
<html>
<head>
<title>Form Elements</title>
</head>
<body>
Input Box <input type="text" name="text">
<br>
    DropDown Select <select name="text">
     <option>First</option>
     <option>Second</option>
       </select>
    <br>
    Text Area<textarea cols="50" rows="5">I m a text area</textarea>
<br>   
    Button <button type="button" name="button">Button</button>

</body>
</html>

Result : 



html form

Simple Login Form Example

<!DOCTYPE html>
<html>
<head>
<title>Form Elements</title>
</head>
<body>
<form action="login.php" method="post">
Email<br> <input type="email" name="email" placeholder="Email">
<br>
    Password <br> <input type="password" name="Password" placeholder="Password">
    <br>
 <button type="submit" name="button">Login</button>
    </form>

</body>
</html>

Result

html login form

Explaination
From line <form> - Here is form beginning form elements pass all data to new page on submitting. Form elements pass only that data which is child element of form.
E.g <form>child Elements</form>
method= method is default get but we can use get or post.
When we use get our data pass through url which we see in url and post 
pass data hidden.
action = action is our url for submitting data on that page like any server side page where it catch that data.( which we see in php tutorial) for now we just pass and server side language catch it.

Other line after that are data elements which contain in its its variable and variable name is name=”value” this value is the variable name which we catch in server side.

Submit = button submit is used to submit our its very important for submitting our forms.




  

Here is a list of Input Types Elements like radio,checkbox,button,date,select

select element and properties
select has a list of child  elements which values we defined inside option element when we submit the form the selected values pass through the form
<option>First</option>   and <option value=”1”>First</option> 
Here you two types of option i declare both is same but if we dont defined (set value=”value”) then option text value will be passed else value attribute value pass.

We can also make default selection of any element by using attribute
selected=”selected”
in option element

We can set the size of select box  like display more than one value at a time  by using.
size=”n” where n= no. Of elements to display 

We can also make multiple selection this time the value will pass in array format.
By using multiple=”multiple” but for using mutiple we have to change name  in array for like my variable name is : -

name=”vegeable”
then i have to change it to

name=”vegetable[]”
if we don’t do that then we only get single selected value only

Simple All Select Example

<!DOCTYPE html>
<html>
<head>
 <title>HTML Select</title>
</head>
<body>
 <form action="http://localhost/form.php"> 
        <select name="fruit">
  <option>Apple</option><option>Mango</option><option>Orange</option>
                    </select><br>
         <select name="animal" size="4">
  <option>Cat</option><option>Dog</option><option>Elephant</option><option>Horse</option><option>Zebra</option>
        </select><br>
        <select name="vegetable[]" size="4" multiple="multiple">
  <option>Potato</option><option>Onion</option><option>Cabbage</option><option>Pea</option><option>Carrot</option>
        </select><br>
        <select name="defaultselected">
  <option>Potato</option><option>Onion</option><option selected="selected">Cabbage</option><option>Pea</option>  <option>Carrot</option>
         </select><br>
         <select name="differntvalue">
  <option value="1">First</option><option value="2">Second</option><option value="3">Third</option><option value="4">Fourth</option>
     <option value="5">Fifth</option>
         </select><br>
         <button type="submit" name="submit">Submit</button> 
   </form>

</body>
</html>

Result

form select

PHP Output

php request
 I Know You all Excited To Check This Form Data After Seeing Output So Jst Use this.
Note : -Make Sure You Install Xampp Or Local Server 


Code : 

<?php
echo "<pre>";
print_r($_REQUEST);
echo "</pre>";

Textarea

Text area  is a large area for writing contents like post,message it is multi line input area.
We can change its no. Of line to occcupied by using attribute
rows=”n” n= no. Of rows
We can change its no. Of column to occupied by using attribute
cols=”n” n= no. Of cols
E.g : <textarea rows=”5” cols=”5”>I am textarea</textarea>

Input Elements

Input Elements is a huge list of types that why am covering this on last topic.
It contain datalist like auto complete data.
It contain checkbox,Radio button
It also contain 3 types of buttons also button,submit,reset
button – Normal Button
submit – Form Submit Button
reset – Reset The Form Data

List Of Types of all Inputs (type=”value” attrribute) 

type=”text” for text input
type=”password” for password hidden values
type=”submit” for submit values in forms
type=”reset” for reseting values in form inputs
type=”radio” for radio button option
type=”checkbox” for multi check boxes (used name in array like name=”language[]”)
type=”color” for color picker
type=”date” for date selecting using calendar
type=”email” for email input
type=”number” for number input
type=”time” for time input 

Input Elements Example

<!DOCTYPE html>
<html>
<head>
<title>Input Elements</title>
</head>
<body>
<form action="http://localhost/form.php" method="post">
Plain Text Box <input type="text" name="name"><br>
Password Field <input type="password" name="password"><br>
Radio Button (Gender E.g): 
<label>Male <input type="radio" name="gender" value="male"><label>Female <input type="radio" name="gender" value="female"></label><br>
CheckBox (Language E.g) :
<label>C++ <input type="checkbox" name="lang[]" value="c++"></label><label>PHP <input type="checkbox" name="lang[]" value="php"></label><br>
Color <input type="color" name="color"><br>
Date (E.g DoB) <input type="date" name="dob" ><br>
Email <input type="email" name="email"><br>
Number (E.g Age) : <input type="number" name="age"><br>
Time <input type="time" name="time" ><br>
<input type="submit" name="submit" value="submit"><input type="reset" name="reset" value="Reset Form Fields">
</form>
</body>
</html>

Result 
html input

html input color

html input date

Result Output in PHP

php request

 Input Attributes

Now We See Different Types Of Inputs Now lets see its Extra Attributes.
value=”value” which set values in input fields.
readonly=”readonly” which only reads values we can’t edit it.
disabled=”disabled”
disabled the input element then it will be not pass data to server.
maxlength=”n” n= length of input field
required=”required” used for validation without filling that field user can’t submit form.
autofocus=”autofocus” which directly focus that field when page loads.
placeholder=”transparent hint values” for display transparent hint values
I added a blog more about how to handle form data in server side using PHP
Check My Blog : -


Link :  PHP REQUEST and GET

 
0

HTML Tutorial Topic 3


HTML Tutorial Topic 3

HTML Tutorial


Topics

  • Today I Cover This All Topics
  • List
  • Blocks
  • Classes and id
  • Iframes
  • Some Useful Tips 

List 

List as we know it contains list of item in ordered or unordered.

Unordered List
  • Apple
  • Mango
  • Guava
  • Orange

Ordered List
  1. Apple
  2. Mango
  3. Guava
  4. Orange
  5. Banana
We Can Create Easily List in HTML By Using
<ul> - for unorder list
<ol> - for ordered list.

<li> is a nested Element Which Comes Inside Both in ul and ol for list Items.

E.g - <ul><li>First Item</li></ul>
We Can Customize List Item Easily Like Ordered List in Roman no. Format or Unordered List Item in square type items.
For Ordered List

We Use Attribute type=”value”

Where Values is
1 = For Number List Items
A= For uppercase Numbered List Item
a= For Lowercase Numbered
I = For Uppercase Roman Numbered
i = For Lowercase Roman Numbered
For UnOrdered List

We Use CSS style=”list-style:values”

Where Values is
circle = For Circle Number List Items
disc = For disc Numbered List Item
square = For Square  Numbered
none = For Simply Print item without Bullets
 
List Example HTML
<!DOCTYPE html>
<html>
<head>
<title>List</title>
</head>
<body>
<p>Unordered List</p>
<ul>
<li>Mango</li>
<li>Guava</li>
<li>Orange</li>
<li>Apple</li>
<li>Banana</li>
</ul>
<p>Ordered List</p>
<ol>
<li>Carrot</li>
<li>Onion</li>
<li>Potato</li>
<li>Tomato</li>
<li>Cabbage</li>
</ol>
</body>
</html>

Result
HTML List



Block and Inline Elements 

Block Elements – Block elements are such elements that stretch full width under body and start with new line.

E.g : <div>,<article>

Inline Elements – Inline Elements are such which does not takes full width cover only small part that it needs.

E.g : <span>,<button> 

Simple Example 

 
<html>
<body>
<div style=”padding:2px;border:1px solid red;margin-bottom: 10px;”>
I am A Block Element, I used Border So it Clearly Show Much It Takes Width, Padding For items don’t touch the Div Border and Margin bottom So i dont Touch the Span
</div>
<span style=”border:1px solid red;padding:2px”>
I am a inline with border and (Padding so i dont Touch the Border Of Span 
</span>
</body>
</html>

Result
HTML Blocks and Inline

Some List Of Block Elements
<div>
<article>
<section>
<header>
<footer>
<main>
<aside>
<form>
<ul>
<ol>
<p>
<pre>
<section>
<table>
<li>
<h1>-<h6>


Some List Of Inline Elements<a>
<button>
<input>
<span>
<select>
<textarea>
<i>
<time>
<img>
<small>



Class and id

Since, We use class and id for select elements  in our webpage by using javascript or css.

We can declare multiple elements in our web page but if we declare multiple then css select the multiple multiple id but js does not select it.

Id is always unique.
We can use multiple class value in element but not in id
E.g
<span class=”first second”>

We select class by using (.) dot and (#) for id.
E.g for id – botton#myfirstid{ color:red }
#myfirstid{ color:red } both is same but in upper it select only button elements.

For class – button.myfirstclass{ color:yellow }
.myfirstclass { color:yellow } both is same but first one select only input elements

 Simple selecting element in css
<html>
<head><style type="text/css">
div.firstclass{  background: red; }
div.secondclass{ color:white; }
div#firstid{ background: grey; color: black; }
</style></head>
<body>
<div class="firstclass">
i am a div which is selected and controlled by css
</div><span>
css not select me because my class is same but i am a span element
</span><div id="firstid">
css control me by my id and element
</div><span id="firstid">
css not control me by my id and element because i am span element
</span><div class="firstclass secondclass">
i a muti class element so firstclass and secondclass both select me
</div>
</body>
</html>


 Result 
html class and id


Iframes

Iframes is used to display a embeded webpage in your current webpage just like adding other webpages or other website.
E.g – we see embed youtube in many sites.
Code : - 
<iframe src=”http://sswebtricks.blogspot.in/width=”100%height=”400px”>

Example 

html iframe
 



Lets Create a iframe

<!DOCTYPE html>
<html>
<head>
<title>Iframe</title>
</head>
<body>
<iframe src="http://sswebtricks.blogspot.in/" width="100%" height="600px"></iframe>

</body>
</html>

Result

Html iframe


Some Useful Tips

For Reloading Webpages after some seconds we use.
<meta http-equiv="refresh" content="30">
  where content= seconds
use this code inside every meta tag comes inside head tag

For Zoom View in Mobile Device or Creating Responsive (i cover this in css) web page we use.
<meta name="viewport" content="width=device-width, initial-scale=1.0">

For writing computer codes or special codes like html in simple,programing language which print in programatic from we use <pre> tag
 Note : this will not execute in web page it just display codes in programatic form.
<pre>Your Codes</pre>

Simple Web Page Layout

<!DOCTYPE html>
<html>
<head>
<title>Simple layout</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<header>Welcome To SuperCoders</header>
<nav>
<a href="#">Home</a>
<a href="#">Post</a>
<a href="#">Signup</a>
</nav>
<aside>
<p>I m a sidebar where some notification comes</p>
</aside>
<main>
<section>
<h2>What is Lorem Ipsum?</h2>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</section>
</main>
<footer>
&copy; SuperCoders 2018
</footer>

</body>
</html>

style.css

body{
margin:0px;
padding: 0px;
}
header{
padding: 10px;
background: orange;
}
aside{
background: tomato;
width: 18%;
padding: 10px;
float: left;
height: 400px;
}
main{
background: red;
width: 78%;
padding: 10px;
float:left;
height: 400px;
}
footer{
text-align: center;
clear: both;
color: white;
background: green;
padding: 10px;
}
nav{
background: pink;
padding: 10px;

}
nav a{
background: yellow;
padding: 5px;
margin: 5px;
}

Result

simple layout html

 

HTML Tutorial Topic 2

HTML Tutorial Topic 2

html tutorial for beginners


0

HTML5 Tutorial Topic 1

HTML5 Tutorial Topic 1

html tutorial

0

Android Autocomplete Location Search

Android Autocomplete Location Search

Android Autocomplete Location Search

  

 

First visit

https://console.developers.google.com/

And Create A New Project And Generate a API key

After That Create A New Android studio Project

Android Autocomplete Location Search


Then edit build.gradle file  and google library dependency


    compile 'com.google.android.gms:play-services-location:11.8.0'
compile 'com.android.volley:volley:1.1.0'


like this in build.gradle.

Google location dependency


After that sync now

gradle sync


Then open AndroidManifest.xml file and add meta for Data And Value for google api which we generate in first step.

AndroidManifest.xml


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.sswebtricks.sanjeev.autocompletelocation">
<uses-permission android:name="android.permission.INTERNET"/>

 
 <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <meta-data android:name="com.google.android.geo.API_KEY" android:value="API KEY PUT HERE"/>
    </application>

</manifest>
Now Create a location model for google place api.
Location Model


LocationModel.java



package com.sswebtricks.sanjeev.autocompletelocation;

import android.util.Log;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;

/**
 * Created by sanjeev on 4/2/18.
 */

public class LocationModel {

    private static final String TAG = LocationModel.class.getSimpleName();

    private static final String URL = "https://maps.googleapis.com/maps/api/place";
    private static final String API_TYPE = "/autocomplete";
    private static final String OUTPUT = "/json";

    private static final String KEY = "YOUR_API_KEY";

    public ArrayList autocomplete (String input) {
        ArrayList resultList = null;

        HttpURLConnection conn = null;
        StringBuilder jsonResults = new StringBuilder();

        try {
            StringBuilder sb = new StringBuilder(URL + API_TYPE + OUTPUT);
            sb.append("?key=" + KEY);
            sb.append("&types=(cities)");
            sb.append("&input=" + URLEncoder.encode(input, "utf8"));

            URL url = new URL(sb.toString());
            conn = (HttpURLConnection) url.openConnection();
            InputStreamReader in = new InputStreamReader(conn.getInputStream());

            int read;
            char[] buff = new char[1024];
            while ((read = in.read(buff)) != -1) {
                jsonResults.append(buff, 0, read);
            }
        } catch (MalformedURLException e) {
            Log.e(TAG, "Api Error", e);
            return resultList;
        } catch (IOException e) {
            Log.e(TAG, "Connection Error", e);
            return resultList;
        } finally {
            if (conn != null) {
                conn.disconnect();
            }
        }

        try {
            JSONObject Object = new JSONObject(jsonResults.toString());
            JSONArray PredictArray = Object.getJSONArray("predictions");

            resultList = new ArrayList(PredictArray.length());
            for (int i = 0; i < PredictArray.length(); i++) {
                resultList.add(PredictArray.getJSONObject(i).getString("description"));
                
                          }
        } catch (JSONException e) {
            Log.e(TAG, "Cannot Parse Json", e);
        }

        return resultList;
    }
}

Location Model Java

Now come to layout file which is activity_main.xml

activity_main.xml



<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.sswebtricks.sanjeev.autocompletelocation.MainActivity">
<LinearLayout
    android:padding="10dp"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <AutoCompleteTextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/autocomplete"
        android:hint="Type in your Location" />
</LinearLayout>
    <LinearLayout
        android:padding="5dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:padding="5dp"
            android:layout_weight="1"
            android:id="@+id/lat"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
        <TextView
            android:padding="5dp"
            android:layout_weight="1"
            android:id="@+id/lng"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

    </LinearLayout>
</LinearLayout>
</RelativeLayout>

It look like this

activity main layout

activity main layout

Now create a layout resource file for list item

list_item.xml


<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textColor="#000"
    android:padding="10dp"
    android:text="Location"
    android:id="@+id/autocompleteText" />

look like this.

list item



Now create LocationAdapter


LocationAdapter.java

package com.sswebtricks.sanjeev.autocompletelocation;

import android.content.Context;
import android.widget.ArrayAdapter;
import android.widget.Filter;
import android.widget.Filterable;

import java.util.ArrayList;

/**
 * Created by sanjeev on 4/2/18.
 */

public class LocationAdapter extends ArrayAdapter implements Filterable {

    ArrayList resultList;

    Context mContext;
    int mResource;

    LocationModel mPlaceAPI = new LocationModel();

    public LocationAdapter(Context context, int resource) {
        super(context, resource);

        mContext = context;
        mResource = resource;
    }

    @Override
    public int getCount() {
        
        return resultList.size();
    }

    @Override
    public String getItem(int position) {
        return resultList.get(position);
    }

    @Override
    public Filter getFilter() {
        Filter filter = new Filter() {
            @Override
            protected FilterResults performFiltering(CharSequence constraint) {
                FilterResults filterResults = new FilterResults();
                if (constraint != null) {
                    resultList = mPlaceAPI.autocomplete(constraint.toString());

                    filterResults.values = resultList;
                    filterResults.count = resultList.size();
                }

                return filterResults;
            }

            @Override
            protected void publishResults(CharSequence constraint, FilterResults results) {
                if (results != null && results.count > 0) {
                    notifyDataSetChanged();
                }
                else {
                    notifyDataSetInvalidated();
                }
            }
        };

        return filter;
    }
}

Now MainActivity.java Code :
 
 
package com.sswebtricks.sanjeev.autocompletelocation;

import android.app.ProgressDialog;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AutoCompleteTextView;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.DefaultRetryPolicy;
import com.android.volley.RequestQueue;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.net.URLEncoder;

public class MainActivity extends AppCompatActivity {

    private ProgressDialog progressDialog;
    TextView tlat;
    TextView tlong;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tlat=(TextView)findViewById(R.id.lat);
        tlong=(TextView)findViewById(R.id.lng);
        progressDialog=new ProgressDialog(this);
        AutoCompleteTextView autocompleteView = (AutoCompleteTextView)findViewById(R.id.autocomplete);
        autocompleteView.setAdapter(new LocationAdapter(getApplicationContext(), R.layout.list_item));
        autocompleteView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView parent, View view, int position, long id) {
             
                String description = (String) parent.getItemAtPosition(position);
                FindLatLong(description);
                Toast.makeText(getApplicationContext(), description, Toast.LENGTH_SHORT).show();
            }
        });
    }
    private void FindLatLong(String description) {

        progressDialog.setMessage("Fetching Details..");
        progressDialog.setCancelable(false);
        progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progressDialog.show();
        RequestQueue queue = Volley.newRequestQueue(getApplicationContext());
        String url = Uri.parse("https://maps.googleapis.com/maps/api/geocode/json")
                .buildUpon()
                .appendQueryParameter("key"Your API KEY")
                .appendQueryParameter("address", URLEncoder.encode(description))
                .build().toString();
        StringRequest sr = new StringRequest(com.android.volley.Request.Method.GET, url, new com.android.volley.Response.Listener() {
            @Override
            public void onResponse(String response) {
                progressDialog.dismiss();
                try {
                    JSONObject jsonObj = new JSONObject(response);
                    if(jsonObj.getJSONArray("results")!=null) {
                        JSONArray destination_addresses = jsonObj.getJSONArray("results");
                        JSONObject geometry= (JSONObject) destination_addresses.get(0);
                        String lat=String.format("%.4f",geometry.getJSONObject("geometry").getJSONObject("location").getDouble("lat"));
                        String lng=String.format("%.4f",geometry.getJSONObject("geometry").getJSONObject("location").getDouble("lng"));
                        Log.d("element", response.toString());
                        tlat.setText("Lat : "+lat);
                        tlong.setText("Long : "+lng);

                    }
                    else{
                        Toast.makeText(MainActivity.this, "Error in finding ", Toast.LENGTH_SHORT).show();
                        progressDialog.dismiss();

                    }


                } catch (JSONException e) {
                    e.printStackTrace();
                    progressDialog.dismiss();

                }
                Log.d("Response", response);

            }
        }, new com.android.volley.Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                progressDialog.dismiss();
                Log.d("Errors", String.valueOf(error));
            }
        });
        queue.add(sr);
        sr.setRetryPolicy(new DefaultRetryPolicy(
                20000,
                DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
    }

}

Now Run Your App And Don't Forget To Put Api Key

MainActivity Auto Complete

Android Auto Complete

Android Auto Complete


Download Complete Source Code
0

PHP Curl Post Tutorial

PHP Curl Post Tutorial

PHP Curl Post Tutorial


Code : - 
<?php
$url="https://reqres.in/api/users";
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,"name=test&job=dev");
curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
$html=curl_exec($ch);
echo $html;
?>

This is same as loading a webpage using php curl here in this we set two more option. 1.post=true for posting data 2.postfields = which is our post data.

Video Tutorial

2

PHP Curl Load Simple Webpage

PHP Curl Load Simple Webpage

PHP fetch web page using curl

Code : - 

<?php
$url="https://jsonplaceholder.typicode.com/posts";
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
$html=curl_exec($ch);
echo $html;
?>

In 2nd line we define our webpage which we have to fetch.
Then in 3rd line we initialize our curl.
In 4th line we set option for curl like url and return transfer etc.
Then we execute our curl and fetch the webpage.

Video Tutorial

0

Android Firebase Messaging

Android Firebase Messaging

Android Firebase Messaging

Step 1. Create New Android Project

Firebase Messaging Project


Step 2. Open 2nd build.gradle file and paste the dependency

compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-messaging:11.8.0'
//and in bottom put this line

apply plugin: 'com.google.gms.google-services'
  
Now its look like this
apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.sswebtricks.sanjeev.firebasetutorial"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }
    }
}


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    compile 'com.google.firebase:firebase-core:11.8.0'
    compile 'com.google.firebase:firebase-messaging:11.8.0'
    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'

Step 2a. Open 1st build.gradle file and paste the classpath
        classpath 'com.google.gms:google-services:3.1.1' // google-services plugin

Now file look like this
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.1.1' // google-services plugin
        

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}


Firebase Gradle Dependency


Step 3. Open AndroidManifest.xml file and paste the service code and notification color for firebase inside application Tag 

<meta-data android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/marker" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorAccent" />
<service
android:name=".MyFirebaseMessagingService">
 <intent-filter>
 <action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
 </service>
 <service
android:name=".MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
AndroidManifest Firebase
Step 4. Create MyFirebaseMessagingService.class which is firebase messaging service which is responsible for receiving our firebase notification
package com.sswebtricks.sanjeev.firebasetutorial;

import android.app.Service;


import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import android.util.Log;


import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

public class MyFirebaseMessagingService extends FirebaseMessagingService {

    private static final String TAG = "MyFirebaseMsgService";

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {

        Log.d(TAG, "From: " + remoteMessage.getFrom());

        if (remoteMessage.getData().size() > 0) {
            Log.d(TAG, "Message data payload: " + remoteMessage.getData());


        }

        if (remoteMessage.getNotification() != null) {
            Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());
        }
        sendNotification(remoteMessage.getNotification().getBody());
    }
    private void sendNotification(String messageBody) {
        Intent intent = new Intent(this, MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
                PendingIntent.FLAG_ONE_SHOT);

        String channelId = getString(R.string.project_id);
        Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.Builder notificationBuilder =
                new NotificationCompat.Builder(this, channelId)
                        .setSmallIcon(R.drawable.marker)
                        .setContentTitle("FCM Message")
                        .setContentText(messageBody)
                        .setAutoCancel(true)
                        .setSound(defaultSoundUri)
                        .setContentIntent(pendingIntent);

        NotificationManager notificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
    }
}

Firebase Message Service

Step 5. Create MyFirebaseInstanceIDService.class which is firebase messaging service for generating our firebase tokens
package com.sswebtricks.sanjeev.firebasetutorial;

import android.app.Service;

/**
 * Created by sanjeev on 31/1/18.
 */

import android.util.Log;

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


public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {

    private static final String TAG = "MyFirebaseIIDService";

    @Override
    public void onTokenRefresh() {
        String refreshedToken = FirebaseInstanceId.getInstance().getToken();
        Log.d(TAG, "Refreshed token: " + refreshedToken);
        sendRegistrationToServer(refreshedToken);
    }

    private void sendRegistrationToServer(String token) {

    }

}

Firebase Instance

Step 6. Create New Project in https://console.firebase.google.com/
Add android to your project and download google-services.json which you got when generating your project.

Step 7. Then from right nav click on Android->then Select Project and Paste the google-services.json in app directory

Firebase google-services.json

Step 8. Now we are Ready to check our messages Go to Firebase Console then Grow->Notifcation and send your test Message

Firebase Notification Dashboard

Step 9. Then Check in Your App

Firebase Notification Tray
Video Tutorial
Download Source Code Download
0