Tutorial by Examples: c

Here is a tested code for image and video.It will work for all APIs less than 19 and greater than 19 as well. Image: if (Build.VERSION.SDK_INT <= 19) { Intent i = new Intent(); i.setType("image/*"); i.setAction...
add permission in your manifest file <uses-permission android:name="android.permission.BLUETOOTH" /> In your Fragment(or Activity) Add the receiver method private BroadcastReceiver mBluetoothStatusChangedReceiver = new BroadcastReceiver() { @Override public void o...
The Java Native Interface (JNI) allows you to call native functions from Java code, and vice versa. This example shows how to load and call a native function via JNI, it does not go into accessing Java methods and fields from native code using JNI functions. Suppose you have a native library named ...
You can add a "Browse Our Other Apps" button in your app, listing all your(publisher) applications in the Google Play Store app. String urlApp = "market://search?q=pub:Google+Inc."; String urlWeb = "http://play.google.com/store/search?q=pub:Google+Inc."; try { I...
The internet is packed with tips for performance improvement of Java programs. Perhaps the number one tip is awareness. That means: Identify possible performance problems and bottlenecks. Use analyzing and testing tools. Know good practices and bad practices. The first point should be done d...
In Java, it's too "easy" to create many String instances which are not needed. That and other reasons might cause your program to have lots of Strings that the GC is busy cleaning up. Some ways you might be creating String instances: myString += "foo"; Or worse, in a loop or...
1. What is MVC? The Model View Controller (MVC) Pattern is a design pattern most commonly used for creating user interfaces. The major advantage of MVC is that it separates: the internal representation of the application state (the Model), how the information is presented to the user (the View...
Here's the utility class: public class SharedPreferencesCompat { public static void putStringSet(SharedPreferences.Editor editor, String key, Set<String> values) { if (Build.VERSION.SDK_INT >= 11) { while (true) { try { ...
put this code inside your ViewHolder note: In this code I am using btnExpand click-event, for whole recyclerview click event you can set listener to itemView object. public class MyViewHolder extends RecyclerView.ViewHolder{ CardView cv; TextView recordName, visibleFile, date, t...
If you just want to get data, but not modify anything, you can turn off change tracking and proxy creation. This will improve your performance and also prevent lazy loading. Bad Example: using(var context = new Context()) { return await context.Set<MyEntity>().ToListAsync().ConfigureAw...
A component can be registered either globally or locally (bind to another specific component). var Child = Vue.extend({ // ... }) var Parent = Vue.extend({ template: '...', components: { 'my-component': Child } }) Thiw new component () will only be available in...
Passing an object to the data property when registering a component would cause all instances of the component to point to the same data. To solve this, we need to return data from a function. var CustomComponent = Vue.extend({ data: function () { return { a: 1 } } })
public class VolleyErrorHelper { /** * Returns appropriate message which is to be displayed to the user * against the specified error object. * * @param error * @param context * @return */ public static String ...
Classes without dependencies can easily be created by dagger. public class Engine { @Inject // <-- Annotate your constructor. public Engine() { } } This class can be provided by any component. It has no dependencies itself and is not scoped. There is no further code necessar...
In order to obtain a Google Maps API key for your certificate, you must provide the API console with the SH1-fingerprint of your debug/release keystore. You can obtain the keystore by using the JDK's keytool program as described here in the docs. Another approach is to obtain the fingerprint progr...
The following abstract defines an EmailAddress type based on the String type which will use a regular expression to validate the passed argument as an e-mail address. If the address isn't valid, an exception will be thrown. abstract EmailAddress(String) { static var ereg = ~/^[\w-\.]{2,}@[\w-\.]...
Windows : for %f in (C:\your_app_path\*.apk) do adb install "%f" Linux : for f in *.apk ; do adb install "$f" ; done
It is perfectly fine to use a package name other than the folder name. If we do so, we still have to import the package based on the directory structure, but after the import we have to refer to it by the name we used in the package clause. For example, if you have a folder $GOPATH/src/mypck, and i...
This is the advanced approach with example class FundsController < ApplicationController def index @funds = Fund.all_funds(current_user) end def show @fund = Fund.find(params[:id]) respond_to do |format| format.html format.pdf do pdf = FundsPdf....
You need to add Gem and PDF MIME:Type inside mime_types.rb as we need to notify rails about PDF mime type. After that we can generate Pdf with Prawn in following basic ways This is the basic assignment pdf = Prawn::Document.new pdf.text "Hello World" pdf.render_file "assignment.p...

Page 349 of 826