wiki - Page 3 of 35 - workassis

Android keep orientation portrait

Option 1

In the AndroidManifest.xml add ‘screenOrientation’ property in activity tag

Option 2

In the onCreate function add the following line of code before setContentView() function

 

By bm on November 3, 2016 | Android | A comment?
Tags: ,

Nodejs Express application generator

Using the express generator tool we can quickly and easy create an application skeleton.

Install express generater

1installing-express-1generator

Use express -h for help

Creating Express application with express generator

syntax

eg

2-express-generater-my-app-1

It will create the folder structure and some required files

3-express-generater-my-appfolderstruct

Go inside your app folder and  execute npm install

after-executing-npm-install

It is ready to start the server

runninf-the-server

 

 

ref : https://expressjs.com/en/starter/generator.html

 

By bm on October 5, 2016 | NodeJs | A comment?
Tags: , ,

Ubuntu Install Oracle Java 8

Add repository

Update

Install Java

Setting Java environment variables

chk java version

Get installation path

Switching between Oracle Java 8 and Java 7

Setting Up JAVA_HOME

Edit /etc/profile (sudo nano /etc/profile ) and add the following

save the file and execute

By bm on October 2, 2016 | ubuntu | A comment?
Tags: , ,

Android Retrofit 2.1 HTTP client

Android Retrofit 2.1  HTTP client :

In this example i have divided in to 5 steps :

1. Add gradle dependency

2. Create models for accessing the final data (in this example, the api response json converting to java object this object class is called model )

3. Create interface to define api end point

4. Create a service class for interacting our java code with retrofit.

5. Make the api calls wherever you required

1. Add Gradle dependency (ref: http://square.github.io/retrofit/ )

2. Create models 

User.java

3. Create interface

ApiInterface.java

expected api response

get/users

get/user

4. Create a service class

ApiService.java

5. Make the api calls

Retrofit supports synchronous and asynchronous request execution.

 Asynchronous Requests

GET calls

GET call with query string/param OR GET call with path string/param

Post call

POST call with body param

POST call with form encoding

 

Synchronous request

You can also call the apis synchronously.

You cannot run this code in main tread you will get exception like ( java.lang.RuntimeException:Unable to start activity ComponentInfo{  …. } android.os.NetworkOnMainThreadException). So better to use synchronous request in services or asyncTask.

networkmainthread

 

 

How to create AsyncTask : http://wiki.workassis.com/android-asynctask

How to create Service : http://wiki.workassis.com/android-intentservice-example

Ref : http://square.github.io/retrofit/

By bm on September 30, 2016 | Android | A comment?
Tags: , ,

Android full screen Activity

Androidmanifest.xml

You need to use NoactionBar theme

Activity class (SplashActivity.java)

By bm on September 29, 2016 | Android | A comment?
Tags: ,

Android GreenDAO Example

There are two step required for implementing Green Dao ORM library in to android project

1. Create generator java module
2. Implement data base interaction in Activity

Step 1. Create generator java module

The generator module contains a single class containing the data model definition. This will automatically generate model class and Dao calss for the database interaction

How to create a generator module?

In android studio got File->New-> New Module select Java Library 

javalib

Give library name and class name

javalib2

After adding the library the folder structure will be like this

befouremoduleexe

add GreenDao dependency in the created module, and sync

for Green dao 3.x please use the plugin

generatergradile

Add the following code in GeneratorClass.java file. Here we defining a users table scema

for Green dao 3.x:- just change the imports

Run GeneratorClass.java file

rungenerator

It will Create a db folder inside out main app package

aftermoduleexe

 

2. Implement data base interaction in Activity

Add Green Dao gradle dependency in our main project and sync

for Green dao 3.x:-

appgradle

MainActivity .java

activity_main.xml

Out Put

greendaooutput

 

Note:-

While running you app you need to set app from tine toolbar and run

note

 

Ref:

http://greenrobot.org/greendao/

By bm on September 28, 2016 | Android | A comment?
Tags: , ,

Ajax
Android
Android XML
ArrayList
Browser
Codeigniter
Css
Drupal 8