1) Services
A service is a constructor function that is invoked once at runtime with new, just like what we would do with plain javascript with only
difference that AngularJs is calling the new behind the scenes.
There is one thumb rule to remember in case of services
Services are constructors...
This ActionResult returns a Razor view page. Under the standard routing template this ActionResult method would be reached at http://localhost/about/me
The View will be looked for automatically in your site at ~/Views/About/Me.cshtml
public class AboutController : Controller
{
public ActionR...
Eclipse debugging starts with what is referred to as Agents.
The JVM, which runs the complied .class sources has a feature that allows externally libraries (written in either Java or C++) to be injected into the JVM, just about runtime. These external libraries are referred to as Agents and they ha...
Note: Let's setup some anonymous authentication for the example
{
"rules": {
".read": "auth != null",
".write": "auth != null"
}
}
Once it is done, create a child by editing your database address. For example:
https://your-proje...
In order to enable writing more complex UI tests the UIAutomatorViewer is needed. The tool located at /tools/ makes a fullscreen screenshot including the layouts of the currently displayed views. See the subsequent picture to get an idea of what is shown:
For the UI tests we are looking for resou...
Putting UIAutomator tests together to a test suite is a quick thing:
package de.androidtest.myapplication;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({InterAppTest1.class, InterAppTest2.class})
public class AppTestSuite {}
...
This example creates a MediaSession object when a Service is started. The MediaSession object is released when the Service gets destroyed:
public final class MyService extends Service {
private static MediaSession s_mediaSession;
@Override
public void onCreate() {
// Insta...
This example assumes that you have already set up a Firebase Realtime Database. If you are a starter, then please inform yourself here on how to add Firebase to your Android project.
First, add the dependency of the Firebase Database to the app level build.gradle file:
compile 'com.google.firebase...
First create a BroadcastReceiver class to handle the incoming Location updates:
public class LocationReceiver extends BroadcastReceiver implements Constants {
@Override
public void onReceive(Context context, Intent intent) {
if (LocationResult.hasResult(intent)) {
...
A repository pattern can be used to encapsulate data storage specific code in designated components. The part of your application, that needs the data will only work with the repositories. You will want to create a repository for each combination of item you store and your database technology.
Read...
We will take vehicle hierarchy example as depicted below.
Vehicle.java
package com.thejavageek.jpa.entities;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance...
The next code illustrates how to find the nearest value of a Enum.
First we define this Enum that will serve to specify search criteria (search direction)
Public Enum EnumFindDirection As Integer
Nearest = 0
Less = 1
LessOrEqual = 2
Greater = 3
GreaterOrEqual = 4
End Enum...
This can be useful if you're writing a game or something that needs to execute a piece of code every a few seconds.
import android.os.Handler;
public class Timer {
private Handler handler;
private boolean paused;
private int interval;
private Runnable task = new Runnable ...
add_action( 'init', function() {
// do something here
} );
Using a function block to hook a set of instructions. With the init hook, the set of instructions will be executed right after wordpress has finished loading the necessary components.