Tutorial by Examples

To check exact strength in decibels use this- ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo Info = cm.getActiveNetworkInfo(); if (Info == null || !Info.isConnectedOrConnecting()) { Log.i(TAG, "No connection");...
A trapezoid can be made by a block element with zero height (height of 0px), a width greater than zero and a border, that is transparent except for one side: HTML: <div class="trapezoid"></div> CSS: .trapezoid { width: 50px; height: 0; border-left: 50px ...
Here is a generic ViewHolder class that you can use with any DataBinding layout. Here an instance of particular ViewDataBinding class is created using the inflated View object and DataBindingUtil utility class. import android.databinding.DataBindingUtil; import android.support.v7.widget.RecyclerVi...
By default the ArrayAdapter class creates a view for each array item by calling toString() on each item and placing the contents in a TextView. To create a complex view for each item (for example, if you want an ImageView for each array item), extend the ArrayAdapter class and override the getView(...
Using Picasso as ImageGetter for Html.fromHtml public class PicassoImageGetter implements Html.ImageGetter { private TextView textView; private Picasso picasso; public PicassoImageGetter(@NonNull Picasso picasso, @NonNull TextView textView) { this.picasso = picasso; this.textView...
It's good practice to mark some warnings in your code. For example, some deprecated methods is need for your testing, or old support version. But Lint checking will mark that code with warnings. For avoiding this problem, you need use annotation @SuppressWarnings. For example, add ignoring to warni...
You can communicate two activities so that Activity A can be notified of an event happening in Activity B. Activity A final String eventName = "your.package.goes.here.EVENT"; @Override protected void onCreate(Bundle savedInstanceState) { registerEventReceiver(); super.onCre...
Unlike for and while loops, do-while loops check the truth of the condition at the end of the loop, which means the do block will execute once, and then check the condition of the while at the bottom of the block. Meaning that a do-while loop will always run at least once. For example this do-while...
A use case that comes across frequently, is creating a String from a stream, where the stream-items are separated by a certain character. The Collectors.joining() method can be used for this, like in the following example: Stream<String> fruitStream = Stream.of("apple", "banana...
To connect to your DocumentDB database you will need to create a DocumentClient with your Endpoint URI and the Service Key (you can get both from the portal). First of all, you will need the following using clauses: using System; using Microsoft.Azure.Documents.Client; Then you can create the ...
Your DocumentDB database can be created by using the CreateDatabaseAsync method of the DocumentClient class. A database is the logical container of JSON document storage partitioned across collections. using System.Net; using System.Threading.Tasks; using Microsoft.Azure.Documents; using Microso...
A collection can be created by using the CreateDocumentCollectionAsync method of the DocumentClient class. A collection is a container of JSON documents and associated JavaScript application logic. async Task CreateCollection(DocumentClient client) { var databaseName = "<your database...
A document can be created by using the CreateDocumentAsync method of the DocumentClient class. Documents are user defined (arbitrary) JSON content. async Task CreateFamilyDocumentIfNotExists(DocumentClient client, string databaseName, string collectionName, Family family) { try { ...
DocumentDB supports rich queries against JSON documents stored in each collection. With a LINQ query IQueryable<Family> familyQuery = this.client.CreateDocumentQuery<Family>( UriFactory.CreateDocumentCollectionUri(databaseName, collectionName), queryOptions) .Where(f => f....
DocumentDB supports replacing JSON documents using the ReplaceDocumentAsync method of the DocumentClient class. await client.ReplaceDocumentAsync(UriFactory.CreateDocumentUri(databaseName, collectionName, familyName), updatedFamily);
DocumentDB supports deleting JSON documents using the DeleteDocumentAsync method of the DocumentClient class. await client.DeleteDocumentAsync(UriFactory.CreateDocumentUri(databaseName, collectionName, documentName));
Deleting a database will remove the database and all children resources (collections, documents, etc.). await this.client.DeleteDatabaseAsync(UriFactory.CreateDatabaseUri(databaseName));
In some cases it may not suffice to know whether more that one methods were called. The calling order of methods is also important. In such case you may use InOrder class of Mockito to verify the order of methods. SomeClass mock1 = Mockito.mock(SomeClass.class); otherClass mock2 = Mockito.mock(Oth...
Set up some constants for the server and authentication information. Assuming LDAPv3, but it's easy enough to change that. // Authentication, and the name of the server. private const string LDAPUser = "cn=example:app:mygroup:accts,ou=Applications,dc=example,dc=com"; private readonly ch...
Assuming LDAPv3, but it's easy enough to change that. This is anonymous, unencrypted LDAPv3 LdapConnection creation. private const string TargetServer = "ldap.example.com"; Actually create the connection with three parts: an LdapDirectoryIdentifier (the server), and NetworkCredentials....

Page 713 of 1336