Tutorial by Examples: ce

The android:process field defines the name of the process where the service is to run. Normally, all components of an application run in the default process created for the application. However, a component can override the default with its own process attribute, allowing you to spread your applicat...
Given the model: class MyModel(models.Model): name = models.CharField(max_length=10) model_num = models.IntegerField() flag = models.NullBooleanField(default=False) We can use Q objects to create AND , OR conditions in your lookup query. For example, say we want all objects that ...
tl;dr : Create a base class that defines two user objects (say user and another_user). Create your other models and define three Client instances. self.client : Representing user logged in browser self.another_client : Representing another_user 's client self.unlogged_client : Representing unlo...
Create a class which extends Service class and in overridden method onBind return your local binder instance: public class LocalService extends Service { // Binder given to clients private final IBinder mBinder = new LocalBinder(); /** * Class used for the client Binder. Bec...
Describe your service access interface through .aidl file: // IRemoteService.aidl package com.example.android; // Declare any non-default types here with import statements /** Example service interface */ interface IRemoteService { /** Request the process ID of this service, to do evil...
SharedPreferences Manager (Singleton) class to read and write all types of data. import android.content.Context; import android.content.SharedPreferences; import android.util.Log; import com.google.gson.Gson; import java.lang.reflect.Type; /** * Singleton Class for accessing SharedPref...
You may pull (download) files from the device by executing the following command: adb pull <remote> <local> For example: adb pull /sdcard/ ~/ You may also push (upload) files from your computer to the device: adb push <local> <remote> For example: adb push ~/im...
You can reboot your device by executing the following command: adb reboot Perform this command to reboot into bootloader: adb reboot bootloader Reboot to recovery mode: adb reboot recovery Be aware that the device won't shutdown first!
If you want to cancel an alarm, and you don't have a reference to the original PendingIntent used to set the alarm, you need to recreate a PendingIntent exactly as it was when it was originally created. An Intent is considered equal by the AlarmManager: if their action, data, type, class, and ca...
__FUNCTION__ returns only the name of the function whereas __METHOD__ returns the name of the class along with the name of the function: <?php class trick { public function doit() { echo __FUNCTION__; } public function doitagain() { echo __METHOD_...
__CLASS__ magic constant returns the same result as get_class() function called without parameters and they both return the name of the class where it was defined (i.e. where you wrote the function call/constant name ). In contrast, get_class($this) and get_called_class() functions call, will both ...
Type hinting for classes and interfaces was added in PHP 5. Class type hint <?php class Student { public $name = 'Chris'; } class School { public $name = 'University of Edinburgh'; } function enroll(Student $student, School $school) { echo $student->name . ' is b...
In this approach, the single is accessed via the static method: Singleton.getInstance(); To enforce only one instance of the singleton, a private static variable retains the instance, while any additional attempts to instantiate an instance are enforced within the constructor. package { publ...
Multiple rows can be inserted with a single insert command: INSERT INTO tbl_name (field1, field2, field3) VALUES (1,2,3), (4,5,6), (7,8,9); For inserting large quantities of data (bulk insert) at the same time, DBMS-specific features and recommendations exist. MySQL - LOAD DATA INFILE MSSQL - B...
Swift let webview = UIWebView(frame: CGRect(x: 0, y: 0, width: 320, height: 480)) Objective-C UIWebView *webview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; //Alternative way of defining frame for UIWebView UIWebView *webview = [[UIWebView alloc] init]; CGRect webviewFr...
A Broadcast receiver is an Android component which allows you to register for system or application events. A receiver can be registered via the AndroidManifest.xml file or dynamically via the Context.registerReceiver() method. public class MyReceiver extends BroadcastReceiver { @Override ...
nuget sources add -name feedname -source http://sourcefeedurl
To find all the files of a certain extension within the current path you can use the following find syntax. It works by making use of bash's built-in glob construct to match all the names having the .extension. find /directory/to/search -maxdepth 1 -type f -name "*.extension" To find ...
Since C# 6.0 exceptions can be filtered using the when operator. This is similar to using a simple if but does not unwind the stack if the condition inside the when is not met. Example try { // ... } catch (Exception e) when (e.InnerException != null) // Any condition can go in here. { ...
You can access SharedPreferences in several ways: Get the default SharedPreferences file: import android.preference.PreferenceManager; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); Get a specific SharedPreferences file: public static final String PREF_FILE_NAM...

Page 18 of 134