Displaying keyword search results 121 - 130
Created by freyo on April 12, 2011 15:13:32 Last update: May 03, 2011 15:20:55
Create new project
$ tools/android create project \ > --package co...Edit res/values/string.xml , add strings for the main screen.
<?xml version="1.0" encoding="utf-8"?> <resourc...Add widgets to main layout ( res/layout/main.xml ).
<?xml version="1.0" encoding="utf-8"?> <LinearL...Edit src/com/android/apkinfo/GetAPKPermissions.java and change contents to:
package com.android.apkinfo; import android...Install the debug package to the emulator:
ant installThe screen should look like: Add display permissions activity. Start by creating a new layout res/layout/display_permissions.xml :
<?xml version="1.0" encoding="utf-8"?> <LinearL...Add the strings used by the new Activity ( res/values/strings.xml ):
<?xml version="1.0" encoding="utf-8"?> <resourc...Add the Display Permissions Activity ( src/com/android/apkinfo/DisplayPermissions.java ):
package com.android.apkinfo; import android...Change src/com/android/apkinfo/GetAPKPermissions.java to invoke the Display Permissions Activity:
package com.android.apkinfo; import android...Declare Display Permissions Activity in AndroidManifest.xml :
<?xml version="1.0" encoding="utf-8"?> <manifes......
Created by Dr. Xi on May 03, 2011 14:27:15 Last update: May 03, 2011 14:28:06
The XML schema for a contact might look like this:
<?xml version="1.0" encoding="UTF-8"?> <schema ...With XML digital signatures , a Signature element is inserted inside the contact element after the contact file is signed. Like this:
<?xml version="1.0" encoding="UTF-8" standalone="n...which no longer validates with the original schema. The schema should be updated to (with the addition of digital signature namespace, schema import and Signature ref ):
<?xml version="1.0" encoding="UTF-8"?> <schema ...
Created by Dr. Xi on April 26, 2011 20:12:01 Last update: April 28, 2011 15:28:12
An XML schema is a definition of XML files, in XML. It plays the same role as old-time DTDs. Overall, an XML schema file looks like this:
<schema attributeFormDefault = (qualified | u...The attribute meanings: targetNamespace : The name space targeted by the current schema definition. It can be any URI. id and version : For user convenience, the W3C spec defines no semantics for them. xml:lang : Natural language identifier defined by RFC 3306 . attributeFormDefault and elementFormDefault : Set default values for the form attribute for attribute and element declarations. blockDefault and finalDefault : Set default values for the block and final attributes for attribute and element declarations. The W3C defined some built-in datatypes . Examples of primitive datatypes are: string ,...
Created by Dr. Xi on April 28, 2011 11:37:23 Last update: April 28, 2011 11:37:23
The Future interface represents the result of an asynchronous computation. Future provides methods to check if the computation is complete, to wait for its completion, and to retrieve the result of the computation. You call one of the three submit methods of ExecutorService to get a Future object: <T> Future<T> submit(Callable<T> task) <T> Future<T> submit(Runnable task, T result) Future<?> submit(Runnable task) Use the first two to retrieve usable results from the computation. The third option returns a Future that returns null upon successful completion. It is used to simply wait for the task to complete, much like Thread.join() .
import java.util.concurrent.Future; import java...
Created by Dr. Xi on April 28, 2011 11:06:03 Last update: April 28, 2011 11:06:03
The Java Executor interface replaces the call new Thread(new RunnableTask()).start() with executor.execute(new RunnableTask()) . The concurrent package provides built-in utility classes to manage threads so that you don't need to worry about them.
import java.util.concurrent.TimeUnit; import ja...
Created by Dr. Xi on April 28, 2011 08:58:03 Last update: April 28, 2011 08:58:03
The java.util.concurrent.atomic package is a small toolkit of classes that support lock-free thread-safe programming on single variables . This is an example of a shared counter without synchronization or lock:
import java.util.concurrent.atomic.AtomicInteger; ...
Created by Dr. Xi on April 26, 2011 21:25:55 Last update: April 27, 2011 11:08:57
The following code validates a web.xml file against the web-app 2.5 schema:
// Java XML validation with schema import java....web.xml used for testing:
<?xml version="1.0" encoding="UTF-8"?> <web-ap...According to Java API doc , validation can also be done while parsing by calling setSchema on the parsing factory. However, validation doesn't work for the SAXParserFactory!
// Java XML validation with schema import java....
Created by freyo on April 21, 2011 11:41:42 Last update: April 21, 2011 11:41:42
How to enable wifi with Java code:
import android.net.wifi.WifiManager; . . ...
Created by freyo on April 20, 2011 12:26:08 Last update: April 20, 2011 12:26:08
When you create a new key with Java keytool , it wraps the public key in a self signed certificate. You can generate a certificate signing request with the keytool -certreq command. After a certificate authority (CA) signs the certificate request, you can import the certificate received (a .crt file) back into the key store. Instead of using a CA, you can sign the certificate request with another key (with openssl, for example). If the certificate is not signed by a CA, you'll receive an error:
$ keytool -import -alias android-root -file androi...To fix the problem, import the certificate of the signer:
$ keytool -import -trustcacerts -file openssl.crt ...Import the certificate again (alias is the alias of the private key whose certificate was...
Created by jk34 on April 19, 2011 15:42:24 Last update: April 19, 2011 15:42:24
Check the __name__ variable to see if the Python module was invoked from the command line. The line prints when the Python script is called from the command line, but doesn't print when it is imported by another Python module with import MyModule .
if __name__ == '__main__': print 'Invoked f...