Displaying keyword search results 111 - 120
Created by freyo on May 06, 2011 16:07:33 Last update: May 06, 2011 16:08:36
-----BEGIN PRIVATE KEY----- MIIEvAIBADANBgkqhki...Certificate:
-----BEGIN CERTIFICATE----- MIIEqDCCA5CgAwIBAgI...Import the key pair to the debug keystore:
$ cat platform.pem platform.x509.pem >platform-key...
Created by freyo on May 05, 2011 14:02:21 Last update: May 05, 2011 14:02:21
The Android Toast widget displays a message for a specified time period, then disappears by itself. It is useful for showing some message to the user but demanding no user interaction. To see how Toast works, follow the say hi example and change the sayHi method to:
// import android.widget.Toast; public void say...This is a screenshot:
Created by freyo on May 05, 2011 09:00:36 Last update: May 05, 2011 09:07:27
This example uses an Intent with Uri scheme tel: to invoke the phone dialer. Create a new project with:
$ ~/android-sdk-linux_86/tools/android create proj...Update the layout res/layout/main.xml to add a text field and a button:
<?xml version="1.0" encoding="utf-8"?> <LinearL...Update the Java class src/com/android/intenttest/CallPhone.java to handle button click and start the built-in phone dialer with Intent :
package com.android.intenttest; import andr...Update AndroidManifest.xml to add CALL_PHONE permission:
<?xml version="1.0" encoding="utf-8"?> <manifes...Install to the emulator and test:
ant installThe phone dialer will be invoked when you click the "Call" button. So how did this happen? The CallPhone activity creates an Intent with action Intent.ACTION_CALL and Uri tel:<a number> and sends it off to Android. Android starts the activity com.android.phone.OutgoingCallBroadcaster because the intent matches the...
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....