Posts

Android runs on an assortment of devices that offer different screen sizes and densities. For applications, Android system provides a consistent development environment across devices and handles most of the work to adjust each application’s user interface to the screen on which it is displayed.

Range of supported Screens:

Android provides support for multiple screen sizes and densities, reflecting the many different screen configurations that a device may have. One can use features of the Android system to optimise the application’s user interface for each screen configuration and ensure that the application not only renders properly, but provides the best user experience possible on each screen.

Click on build.gradle(Module:app) and add the following library under the dependencies

//Add Library compile 'com.github.chrisbanes:PhotoView:1.2.6'

Step 6: Sync Gradle

To test the code you can take the same image and test it on different devices.

Also, to check you can delete the previous LDPI, MDPI, HDPI, XHDPI formats. Then load a picture which is less clear and compare it with the XXHDPI and XXXHDPI image.(This step has particularly been done to show the difference that the image is picked by the application with respect to the Screen Resolution)

The picture will adjust according to the Resolution of the Screen(ppi density).

We may need to create different versions of an APK file based on an application type (free or paid application), the server environment type (QA, UAT) & etc.

To reduce the convolution of making different versions of an APK file, Android Studio uses Gradle, a build toolkit, to automate and manage the build process. It allows us to define flexible custom build configurations. Each build configuration can define its own set of code and resources while reusing parts common to all the application versions. It enables us to have multiple similar versions of an app within a single code base like different colors, dependencies & etc.

Step 1: Create a New Project with Android Studio.

Name the Application to {anything of your choice} & then click Next. I have currently named it buildvariant.

Step 2: Configure your app

Select the API Version (I took it as 15) as per your Target Audience. Under Phone and Tablet select the API and the click Next.

Select Empty Activity and then click Next.

Keep the Activity name as MainActivity (or any name of your choice) and click Finish.

MainActivity is the Default name

Step 3: Project Settings

Under the heading Gradle Scripts browse for build.gradle(Module:app)

Append the build.gradle file with the following under the buildTypes DSL:

Step 8. In the AndroidManifest.xml check for the activity and make sure on keeping it attached to the SplashActivity.

Step 9. Hallelujah we are done, now Debug your Application according to the build variant.

OUTPUT

Have you ever wanted to control your electrical devices with just the touch of a screen. This can be done via Internet of Things.

The Internet of things (IoT) is the inter-networking of physical devices, vehicles (also referred to as “connected devices” and “smart devices”), buildings, and other items embedded with electronics, software, sensors, actuators, and network connectivity which enable these objects to collect and exchange data.

In this tutorial you will learn how to control a led bulb using your phone or computer from anywhere. The Internet of things (IoT) is the inter-networking of physical devices, vehicles (also referred to as “connected devices” and “smart devices”), buildings, and other items embedded with electronics, software, sensors, actuators, and network connectivity which enable these objects to collect and exchange data.For setup you will need :

Step 8:

If you are into the hacking techniques, you sure must have heard of this popular terminology XSS (Cross-Site Scripting). This is one of the techniques rather a vulnerability in which an attacker/hacker can input something (harmful mostly) which is sent to unsuspecting victims.

What follows below will get you up to speed on the fundamental concept in just a few paragraphs.

XSS is amongst the most rampant of web application vulnerabilities and occurs when a web application makes use of unvalidated or unencoded user input within the output it generates.

In XSS, an attacker does not target a victim directly. Instead, an attacker would exploit a vulnerability within a website or web application that the victim would visit, essentially using the vulnerable website as a vehicle to deliver a malicious script to the victim’s browser.

How XSS works

In order to run malicious JavaScript code in a victim’s browser, an attacker must first find a way to inject a payload into a web page that the victim visits. Of course, an attacker could use social engineering techniques to convince a user to visit a vulnerable page with an injected JavaScript payload.

In order for an XSS attack to take place the vulnerable website needs to directly include user input in its pages. An attacker can then insert a string that will be used within the web page and treated as code by the victim’s browser.

The consequences of malicious JavaScript

Cookie theft: The attacker can access the victim’s cookies associated with the website

Keylogging: The attacker can register a keyboard event listener using javascript and then send all of the user’s keystrokes to his own server, potentially recording sensitive information such as passwords and credit card numbers.

Phishing: The attacker can insert a fake login form into the page using DOM manipulation, set the form’s action attribute to target his own server, and then trick the user into submitting sensitive information.

Types of XSS

While the goal of an XSS attack is always to execute malicious JavaScript in the victim’s browser, there are few fundamentally different ways of achieving that goal. XSS attacks are often divided into three types:

Persistent XSS: where the malicious string originates from the website’s database.

Reflected XSS: where the malicious string originates from the victim’s request.

DOM-based XSS: where the vulnerability is in the client-side code rather than the server-side code.

The Facebook Messenger Platform gives any Business the ability to have conversations with people on Messenger. Any Business can use Facebook Messenger to have more meaningful and personalized conversations if they are able to identify the Facebook user as customer who already has a customer account with your Business.

Facebook has come up with Account Linking feature that allows any Business to invite users to log-in using their own authentication flow and link with their customer account. This helps any business to provide a more secure, personalized and relevant experience to users.

Here is the Step by Step Guide on how any Business can use Facebook Messenger to link their Customer Account:

Assumption

Before I can explain how to Link an Account, I’m assuming that you have an understanding of how to use Facebook messenger for conversations with the users and already have build basic FB messenger Bot linked with backend. We will be focussing only on Account linking feature and will leave it for you to explore how the FB messenger can be used for linking Business Account.

Create a HTML or link your existing Login Page. This is your business hosted Login Page and is fully customizable by the business. Make sure the login page URL is on https else Facebook will not allow you to link the account.

The “url” above is the URL of the Login Page that is referred in Step 1 above. For more information refer Facebook documentation. The above URL is called <yourAccountLinkingUrl> by Facebook documentation

When on Facebook Messenger, FB user clicks on Login Button, the “url” defined above is invoked and redirect_uri and account_linking_token parameters are appended to your url. Both the parameters can be saved on the Login Page so that appropriate response can be passed to facebook after successful Login. Here is the snapshot of how the url will look like:

On Login Page, where there is business validation of successful login, at same place we need to move control to facebook by calling the redirect_uri and appending authorization_code

<redirect_uri>
&authorization_code=AUTHORIZATION_CODE

The authorization_code can be your customer id or any other token that helps to uniquely identify the business customer. For more details, Refer to Facebook Documentation

As soon as successful redirect happens to FB messenger, The Webhook permission will send account linking callback to the code with following details:

Authorization Code : This is the code that uniquely identifies the customer in your business database

Page Scope Id : This is the unique id of a Facebook user for a particular page that will be made available till the time the account is unlinked.

The Business app should save the Page Scope Id in your database so that when next time the same user comes we dont have to ask him to follow the Account Linking process.

Once all the above steps are completed, Any time the same Facebook user interacts on messenger with your business Bot, you will receive the same Page Scope Id which you can match with your database and provide personalized experience to your business customers.

I hope the above guide will help you link your Facebook Bot with your business account and help personalize customer experience.