Sunday, 19 July 2015

Android MySQL Database Operations

In this post we are going to learn about how to connect to MySQL Database from your Android Application and perform database operations. Here we create an android app that contain some login Activity through which the user can retrieve information from database and a registration Activity through which the user can add information into the database. 

First you need to have the following components installed in your development machine. 
1. Database : Here we use the MySQL database.
2. Web Server : Here we use the Apache Web Server.
3. Server side Scripting Language :  Here we use PHP for server side scripting.
4. Android Development environment : You must install android sdk and android studio.  

I recommend you to download and install WAMPSERVER. The wamp server installer contains the following components.
Apache Server Application
MySQL Database
PHP/phpMyAdmin

First we have to create the database and table in MySQL. You can use the phpMyAdmin for mange your MySQL databases. Here our database name is "webappdb" and table name is "user_info".  
The table contains three columns "name", "user_name" and "user_pass". 

For our android application create a new folder inside the public directory of the wamp server and name the folder as "webapp".
First we have to write the needed php scripts and put it in the public directory of the wamp server. Here we need three php scripts, first one is for establish a connection with the database, second one for add informations into database and the last one for retrieve informations.

1. init.php
 <?php  
$db_name = "webappdb";
$mysql_user = "root";
$mysql_pass = "root";
$server_name = "localhost";
$con = mysqli_connect($server_name,$mysql_user,$mysql_pass,$db_name);
?>

2. register.php
 <?php  
require "init.php";
$name = $_POST["user"];
$user_name = $_POST["user_name"];
$user_pass = $_POST["user_pass"];
$sql_query = "insert into user_info values('$name','$user_name','$user_pass');";
?>

3. login.php
 <?php  
require "init.php";
$user_name = $_POST["login_name"];
$user_pass = $_POST["login_pass"];
$sql_query = "select name from user_info where user_name like '$user_name' and user_pass like '$user_pass';";
$result = mysqli_query($con,$sql_query);
if(mysqli_num_rows($result) >0 )
{
$row = mysqli_fetch_assoc($result);
$name =$row["name"];
echo "Login Success..Welcome ".$name;
}
else
{
echo "Login Failed.......Try Again..";
}
?>



Create an android application contain a Login Activity and Register Activity. 

activity_main.xml (Login Activity layout)
 <LinearLayout 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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
android:background="#0BB990"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login Form"
android:textAppearance="?android:textAppearanceLarge"
android:textStyle="bold"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
/>
<EditText
android:layout_width="250dp"
android:layout_height="wrap_content"
android:hint="User Name"
android:id="@+id/user_name"
android:layout_gravity="center_horizontal"
android:layout_marginTop="70dp"
/>
<EditText
android:layout_width="250dp"
android:layout_height="wrap_content"
android:hint="Password"
android:id="@+id/user_pass"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:inputType="textPassword"
/>
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="Login"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:onClick="userLogin"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Register Now"
android:layout_gravity="center_horizontal"
android:layout_marginTop="50dp"
android:onClick="userReg"
/>
</LinearLayout>
android-localhost
register_layout.xml (Register Activity Layout)
 <LinearLayout 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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.easyway2in.mysqlconnect.Register"
android:orientation="vertical"
android:background="#0BB990"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Registration Form"
android:textAppearance="?android:textAppearanceLarge"
android:textStyle="bold"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
/>
<EditText
android:layout_width="250dp"
android:layout_height="wrap_content"
android:hint="Name"
android:id="@+id/name"
android:layout_gravity="center_horizontal"
android:layout_marginTop="40dp"
/>
<EditText
android:layout_width="250dp"
android:layout_height="wrap_content"
android:hint="User Name"
android:id="@+id/new_user_name"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
/>
<EditText
android:layout_width="250dp"
android:layout_height="wrap_content"
android:hint="Password"
android:id="@+id/new_user_pass"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:inputType="textPassword"
/>
<Button
android:layout_width="130dp"
android:layout_height="wrap_content"
android:text="Register"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:onClick="userReg"
/>
</LinearLayout>

android-database-tutorial

In this tutorial we use the HttpUrlConnection instead of HttpClient. HttpClient is deprecated form API level 22.
Ads By Google



Here the server is localhost and we test the application on an android virtual device. We need two URL. First one for registration purpose and the second one is for user Login.

Register URL : ""http://10.0.2.2/webapp/register.php";
Login URL"http://10.0.2.2/webapp/login.php";

Here we use the IP (10.0.2.2) -because the android virtual device use this default IP for connect to the localhost. You can also use your local computer IP address. This application use an AsyncTask to perform the server operations. 

MainActivity.java
 package com.easyway2in.mysqldbdemo;  
import android.app.Activity;
import android.content.Intent;
import android.os.StrictMode;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
public class MainActivity extends Activity{
EditText ET_NAME,ET_PASS;
String login_name,login_pass;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ET_NAME = (EditText)findViewById(R.id.user_name);
ET_PASS = (EditText)findViewById(R.id.user_pass);
}
public void userReg(View view)
{
startActivity(new Intent(this,Register.class));
}
public void userLogin(View view)
{
login_name = ET_NAME.getText().toString();
login_pass = ET_PASS.getText().toString();
String method = "login";
BackgroundTask backgroundTask = new BackgroundTask(this);
backgroundTask.execute(method,login_name,login_pass);
}
}


BackgroundTask.java
 package com.easyway2in.mysqldbdemo;  
import android.app.AlertDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.widget.Toast;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
/**
* Created by prabeesh on 7/14/2015.
*/
public class BackgroundTask extends AsyncTask<String,Void,String> {
AlertDialog alertDialog;
Context ctx;
BackgroundTask(Context ctx)
{
this.ctx =ctx;
}
@Override
protected void onPreExecute() {
alertDialog = new AlertDialog.Builder(ctx).create();
alertDialog.setTitle("Login Information....");
}
@Override
protected String doInBackground(String... params) {
String reg_url = "http://10.0.2.2/webapp/register.php";
String login_url = "http://10.0.2.2/webapp/login.php";
String method = params[0];
if (method.equals("register")) {
String name = params[1];
String user_name = params[2];
String user_pass = params[3];
try {
URL url = new URL(reg_url);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
//httpURLConnection.setDoInput(true);
OutputStream OS = httpURLConnection.getOutputStream();
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(OS, "UTF-8"));
String data = URLEncoder.encode("user", "UTF-8") + "=" + URLEncoder.encode(name, "UTF-8") + "&" +
URLEncoder.encode("user_name", "UTF-8") + "=" + URLEncoder.encode(user_name, "UTF-8") + "&" +
URLEncoder.encode("user_pass", "UTF-8") + "=" + URLEncoder.encode(user_pass, "UTF-8");
bufferedWriter.write(data);
bufferedWriter.flush();
bufferedWriter.close();
OS.close();
InputStream IS = httpURLConnection.getInputStream();
IS.close();
//httpURLConnection.connect();
httpURLConnection.disconnect();
return "Registration Success...";
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
else if(method.equals("login"))
{
String login_name = params[1];
String login_pass = params[2];
try {
URL url = new URL(login_url);
HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
OutputStream outputStream = httpURLConnection.getOutputStream();
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream,"UTF-8"));
String data = URLEncoder.encode("login_name","UTF-8")+"="+URLEncoder.encode(login_name,"UTF-8")+"&"+
URLEncoder.encode("login_pass","UTF-8")+"="+URLEncoder.encode(login_pass,"UTF-8");
bufferedWriter.write(data);
bufferedWriter.flush();
bufferedWriter.close();
outputStream.close();
InputStream inputStream = httpURLConnection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"iso-8859-1"));
String response = "";
String line = "";
while ((line = bufferedReader.readLine())!=null)
{
response+= line;
}
bufferedReader.close();
inputStream.close();
httpURLConnection.disconnect();
return response;
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
@Override
protected void onProgressUpdate(Void... values) {
super.onProgressUpdate(values);
}
@Override
protected void onPostExecute(String result) {
if(result.equals("Registration Success..."))
{
Toast.makeText(ctx, result, Toast.LENGTH_LONG).show();
}
else
{
alertDialog.setMessage(result);
alertDialog.show();
}
}
}

Add the Internet permission in Manifest file.
 <uses-permission android:name="android.permission.INTERNET"></uses-permission>"  

Watch Video Tutorial Of this Topic

Download This Android Studio Project
   
This is how an android application connect to MySQL database run on a remote server and perform basic database operations. I hope you got the concepts. Please share your experience via comments.


Saturday, 18 July 2015

How to share pictures from Google Photos, using shareable-links

This article describes how to get a link to one ore more photos from your Google Photos collection, using the Shareable Link controls.   It also explains how to delete shareable links that you have made in the past



Google Photos is a tool for managing picture collections. It replaces Google+ Photos, and works alongside Picasa-web-albums.   You can read more about it here.

Shareable Links are a new type of linking introduced in Google Photos, which let you easily share one or more pictures at the same time.   You can email them, or use them in tools like Facebook.

When someone opens a shareable link, they see a display with the date, the name and picture of the person who is logged in to Google at the time, and all the pictures that are included in the same shareable link.

If you want to use an image from Google Photos in a tool which cannot use shareable links, you need to find the URL for the photo, instead.


How to get the shareable link for one photo in Google Photos

Log in to Google Photos

Navigate to the picture that you want to get the link for.  

Click on the picture, so you see it in full screen mode.

Hover your mouse towards the top-right of the screen, and you will see some control show up: these are quite small, and are white (so may be harder to see against some backgrounds).

One of the controls is the Share icon:  it looks like a side-ways triangle with one bar missing.     Click it.




In the Share pop-up that opens, click "Get shareable link"




Wait while Photos generates a link.

When it is finished, copy the link text.  
(Ctrl/c on the keyboard is the easiest way to do this, since the text is automatically selected).




Job done! The display address for the photo which you were looking at is in your computer's memory, and you can paste it (with ctrl/v or Edit > Paste) into any other place that wants it (eg Facebook, in an email message, or something that will accept an address which displays the photo inside a "wrapper" of some sort.  s photo-insert wizard, or an email message or discussion forum or chat window).


How to get the shareable link for more than one picture

You can share several (or lots) of photos with someone by just giving them one web-address, which opens up a screen with all the photos.

 To do this:

Click the small selection icon (tick) at the top left hand side of each picture that you want to include.
(Once a photo is selected, the icon shows as blue, and there is a border around the picture).





Hover your mouse towards the top-right of the screen, and you will see some control show up: these are quite small, and are white (so may be harder to see against some backgrounds).




Click the Share control icon:  it is the one that the arrow is pointing to in the picture just above this.

Continue in the same way as for getting a shareable link to an individual photo (ie the section above)



What does the Delete link do

You may have noticed that there is a delete function on the Shareable link screen.


If you click it, then you are given the chance to delete any existing links to the currently selected group of photos.


This doesn't seem to make any sense at the time when you are first making the link.

But it also works later on:  if you have the same photos selected and choose to get the shareable link again, you will get the same link - and you may delete it instead.

This does not delete the photos themselves, just the previous link to the currently-selected group of photos.   If anyone (or anything, eg Facebook) tries to use that link again, they will get an error message instead.

Another way to delete links is from the left-side menu in Photos:  Choosing  More > Shared links shows you al list of all shareable links you have ever made, and then for each one you can either copy the link or delete it.





Where to find more information

Introduction to Google Photos

How to put a picture into a post in Blogger

Thursday, 16 July 2015

Free AddmefastBot 1k Point+/Hour [Private Bot]







If you want the bot, send me message: rexsniper66@gmail.com

Subject: Request AddmefastBot

Which Hashtag Instagram Widget Should You Choose?

There are apps and widgets for almost everything, but one thing that is lacking is a widget that connects one of the most popular image-based social network to your website. Unfortunately, Instagram has yet to design an official widget that will allow you to easily and quickly embed grams on your website.

A widget is like a desk accessory that allows an end user to execute a particular function within a webpage. It fetches information from a particular source and then display it on an intended area. It can be designed to provide easy accessibility to weather, maps, sports updates, calendar and many others. Android and WordPress are two of the biggest contributors of web and mobile widgets, but Instagram still has to catch up.

While they're still trying to figure out how to make an Instagram widget, take advantage of any of the third-party widgets for Instagram. But because there are plenty of them out there, choosing the right one can be tough. Well, we did the sorting and guesswork out for you and presented you with the top 3 options:
instagram widget, instagram

Instansive

Instansive is a widget generator for Instagram that you can use for free or for a fee. Both versions practically have the same features, except for the number of times that the photos refreshes. It only happens once per day with the free version, but is always up to date with the premium version. If you want to do away with the restrictions of this Instagram widget, be ready to make a tiny investment.

instagram widget instansive


Instansive Features

  • Display photos and hashtags in grid, slideshow or column.
  • Customize the number of columns and rows
  • Add a hover effect
  • Show or hide image captions
  • Photos are linked directly to Instagram
  • Offers native support for Drupal and WordPress
For a one-time fee of $5, you can upgrade to the premium version.

Instansive, however, is not perfect compared to other third-party widgets for Instagram, because it has limited features in terms of customization, display, and refresh frequency. Even if you pay the minimal fee, only the photos will be kept up-to-date, but no other features will be added. But look on the bright side, it is responsive.


Intagme

Intagme is pretty simple and straightforward, which can be a bonus if you have to manage plenty of social media accounts and widgets. Its features also get the job done.

instagram widget intagme


Intagme Features

  • Pull photos or hashtags and display them in grid or slideshow
  • Get to customize the layout, thumbnail, size and image padding
  • Edit photos by adding borders and/or background color
On top of all these, Intagme is 100% free, which would probably put all other third-party widgets at the bottom of your list. Before you make a final decision, however, know that Intagme lacks one display feature - column, similar to what you will see on Pinterest. It is not responsive and has limited customization options. Moreover, photos are linked to a page on Intagme.com, instead of directly to Instagram.

Related: How to Add an Instagram Widget in Blogger

SnapWidget

Among Instagram widgets, snap widget is the most popular and is used by more than 100,000 websites daily. It can be used free or for a monthly fee of $6.99.

instagram widget snapwidget

SnapWidget Features

  • Pull photos or hashtags, then display them in grid, board, slideshow, map or scrolling.
  • Thumbnail size and layout can be customized
  • Background color hover effect layout and photo padding can be used to customize photos
  • Show or hide sharing buttons

Features of Premium Version

  • All of the above
  • Create up to 10 widgets
  • Filter photos by username & hashtag
  • Link photos to Instagram or any other page add custom CSS if so desired
  • Has more advanced customization options, such as pagination controls integration of Google Analytics and photo pop-up functionality
For a price of $6.99 per month, this Instagram widget is a worthy investment, especially because the free version is ad supported. This means thumbnails are linked to a SnapWidget page where photos appear alongside ads. An added bonus is that whether free or paid, there is an option available that lets you make the widget responsive for mobile use.

Which Instagram Widget Should You Choose?

Even if only 3 options were presented, making a choice is still not a walk in the park, but at least you don't need to shuffle through tons of widgets. From the information above, you can make an informed decision as to which Instagram widget to use. Or, you can narrow down your options based on your budget - whether you have one or not, the features you need, and how much customization control you want to have.

You should also think about how an Instagram widget can affect your SEO efforts. If you want it to be SEO friendly as the rest of your website, find out how it was developed or rendered, as some of the platforms used may not be visible to search engines. Consider all the factors above and your work will be easier.

Tuesday, 14 July 2015

Route Z v1.1 MOD Apk [Unlimited Money]+[OBB Data]

Route Z,Route Z Game Free Download,Route Z Android Mobile Game,Route Z Android Game Download,Route Z Android Download,Route Z Download,Route Z 2015 Game Free Download,Route Z v1.1 MOD ,Route Z v1.1 MOD  Download,Route Z v1.1 MOD  Android Download,Route Z v1.1 MOD Game Download,Route Z v1.1 MOD Mobile Download,Route Z v1.1 MOD 2015 Download,Route Z v1.1 MOD Apk,Route Z v1.1 MOD Apk Download,Route Z v1.1 MOD Apk [Unlimited Money]+[OBB Data],Route Z v1.1 MOD Apk [Unlimited Money],Android 2016 Game Free Download,Android Mobile 2015 Game Free Download,Android 2016 Games Free Download,Android Games Free Download,
Route Z v1.1 MOD Apk
Route Z
The world’s been overrun by zombies, everyone you’ve ever known has perished and you’re running out of gas. There’s only one route left.
In Route Z, your goal is quite simple: drive to survive! Barrel through hordes of zombies in search of fuel and armor. How far can you make it without wrecking your ride?
Route Z,Route Z Game Free Download,Route Z Android Mobile Game,Route Z Android Game Download,Route Z Android Download,Route Z Download,Route Z 2015 Game Free Download,Route Z v1.1 MOD ,Route Z v1.1 MOD  Download,Route Z v1.1 MOD  Android Download,Route Z v1.1 MOD Game Download,Route Z v1.1 MOD Mobile Download,Route Z v1.1 MOD 2015 Download,Route Z v1.1 MOD Apk,Route Z v1.1 MOD Apk Download,Route Z v1.1 MOD Apk [Unlimited Money]+[OBB Data],Route Z v1.1 MOD Apk [Unlimited Money],Android 2016 Game Free Download,Android Mobile 2015 Game Free Download,Android 2016 Games Free Download,Android Games Free Download,
Game Features:
• Cruise through 3 different landscapes with procedurally generated terrains
• Equip and upgrade 4 deadly weapons to help wreak havoc on your enemies
• Unlock 8 unique vehicles with distinct handling and varied attributes
• Build monster combos to increase your score and stain the streets with zombie remains
• Go into Beast Mode to bust through any obstacle and terrorize the undead
• Complete tons of missions to level up and utilize an array of killer boosts
• Choose between tilt or touch input for maximum control
• Ride in style with gorgeous HD graphics
• Toggle gore effects on or off for younger players
• Scale graphics up or down to suit your device
• Save support lets you sync your save data across all your Android devices
• Share your top scores via Facebook – finally prove to your friends who’d last the longest in the zombie apocalypse
• Localized Menu Support: 中文, Deutsch, Español, Français, Italiano, Magyar, Русский
What’s New
Fixes:
+ Fixed IAP issues some users were experiencing
+ Fixed Cloud syncing issues
+ German localization fix
Changes:
+ Full Android TV Support
+ Extended controller support: Moga Pro B-Mode, Nexus Player Remote/Gamepad, NVIDIA shield, XBOX360/PS3/PS4 gamepad, Samsung Gamepad, FireTV remote/gamepad, General Android TV Remote/Gamepad
Screenshots
Route Z,Route Z Game Free Download,Route Z Android Mobile Game,Route Z Android Game Download,Route Z Android Download,Route Z Download,Route Z 2015 Game Free Download,Route Z v1.1 MOD ,Route Z v1.1 MOD  Download,Route Z v1.1 MOD  Android Download,Route Z v1.1 MOD Game Download,Route Z v1.1 MOD Mobile Download,Route Z v1.1 MOD 2015 Download,Route Z v1.1 MOD Apk,Route Z v1.1 MOD Apk Download,Route Z v1.1 MOD Apk [Unlimited Money]+[OBB Data],Route Z v1.1 MOD Apk [Unlimited Money],Android 2016 Game Free Download,Android Mobile 2015 Game Free Download,Android 2016 Games Free Download,Android Games Free Download,
Route Z v1.1 MOD Apk

Route Z,Route Z Game Free Download,Route Z Android Mobile Game,Route Z Android Game Download,Route Z Android Download,Route Z Download,Route Z 2015 Game Free Download,Route Z v1.1 MOD ,Route Z v1.1 MOD  Download,Route Z v1.1 MOD  Android Download,Route Z v1.1 MOD Game Download,Route Z v1.1 MOD Mobile Download,Route Z v1.1 MOD 2015 Download,Route Z v1.1 MOD Apk,Route Z v1.1 MOD Apk Download,Route Z v1.1 MOD Apk [Unlimited Money]+[OBB Data],Route Z v1.1 MOD Apk [Unlimited Money],Android 2016 Game Free Download,Android Mobile 2015 Game Free Download,Android 2016 Games Free Download,Android Games Free Download,
Route Z v1.1 MOD Apk

Route Z,Route Z Game Free Download,Route Z Android Mobile Game,Route Z Android Game Download,Route Z Android Download,Route Z Download,Route Z 2015 Game Free Download,Route Z v1.1 MOD ,Route Z v1.1 MOD  Download,Route Z v1.1 MOD  Android Download,Route Z v1.1 MOD Game Download,Route Z v1.1 MOD Mobile Download,Route Z v1.1 MOD 2015 Download,Route Z v1.1 MOD Apk,Route Z v1.1 MOD Apk Download,Route Z v1.1 MOD Apk [Unlimited Money]+[OBB Data],Route Z v1.1 MOD Apk [Unlimited Money],Android 2016 Game Free Download,Android Mobile 2015 Game Free Download,Android 2016 Games Free Download,Android Games Free Download,
Route Z v1.1 MOD Apk
Downloads
Route Z v1.1 Apk(10MB) | Mirror
Route Z v1.1 MOD Apk(10 MB)| Mirror
Route Z v1.1 Obb Data(43 MB)| Mirror