Tutorial by Examples: c

In certain cases we need to cancel an image download request in Picasso before the download has completed. This could happen for various reasons, for example if the parent view transitioned to some other view before the image download could be completed. In this case, you can cancel the image down...
A BroadcastReceiver is basically a mechanism to relay Intents through the OS to perform specific actions. A classic definition being "A Broadcast receiver is an Android component which allows you to register for system or application events." LocalBroadcastManager is a way to send ...
AsyncTask is an abstract Class and does not inherit the Thread class. It has an abstract method doInBackground(Params... params), which is overridden to perform the task. This method is called from AsyncTask.call(). Executor are part of java.util.concurrent package. Moreover, AsyncTask contains 2 ...
These are URL schemes supported by native apps on iOS, OS X, and watchOS 2 and later. Opening link in Safari: Objective-C NSString *stringURL = @"http://stackoverflow.com/"; NSURL *url = [NSURL URLWithString:stringURL]; [[UIApplication sharedApplication] openURL:url]; Swift: let s...
To open an app with defined URL scheme todolist://: Objective-C NSURL *myURL = [NSURL URLWithString:@"todolist://there/is/something/to/do"]; [[UIApplication sharedApplication] openURL:myURL]; Swift let stringURL = "todolist://there/is/something/to/do" if let url = NSURL(s...
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo Info = cm.getActiveNetworkInfo(); if (Info == null || !Info.isConnectedOrConnecting()) { Log.i(TAG, "No connection"); } else { ...
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");...
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...
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...
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));
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...

Page 441 of 826