Pages Navigation Menu

Coding is much easier than you think

Difference between development mode and deployment mode in wicket

Posted by in Java, wicket

 

Development mode

 
Development mode in wicket does everything to Developers easy and develop the application very fast . It aids and helps them a lot ,hence it is called as Development mode
 
1. Exceptions are shown in full:
 
we will get full descriptive exception on page and full details of exception on page when it occurs in development mode.
 
2.Wicket debugger is shown:
 
We can get many wicket debugger on page which helps in finding the flow of application request. Main debugger is Wicket Ajax Debugger. It helps the developer for debugging Ajax request . It will present in page and each request and response , java script implementation can be seen.
 
3.Check for serialization errors:
 
We can check all serialization errors in development mode .
 
4.Check for errors in the component hierarchy:
 
When the exception or error in application flow , we get full description and specification of the error and in which component the error occurs. We will get due to what problem we get that error in component for example ” wicket component :text message is not added to page” .
 
5.Disable minimization of html and show wicket tags and attributes:
 
One of important feature development mode is we get can disable minimization of html and wicket tags and attributes is showed . This means when we press F12 (developer mode ) in browser while application is running , we can see
wicket tags and attributes . This will be very useful for debugging mainly CSS and presentation flaws .
 
6.Disabling caching and Disabling Compression of JavaScript:
 
Disabling caching and Disabling Compression of JavaScript is done in development mode.
 

Note : All these things take CPU time and make requests slow(er).

 

Deployment mode


 
In deployment mode , we do everything to make the life of the users better. This means disabling all the stuff that helps developers .
 
1. Disable component hierarchy checks (only the things that prevent Wicket from rendering, i.e. fatal errors, are now reported)
 
2.Enable caching of resources,
 
3.Remove wicket tags and attributes
 
4.Enable minimization of JavaScript.
 
Note : Disabling these things save on CPU cycles and that makes the requests faster.

 
Each of these settings can be tweaked to your advantage, for example you can enable resource watching in DEPLOYMENT mode, to enable modifications to markup and resources on your production boxes.
 
Warning :NEVER EVER deploy your production application using DEVELOPMENT, not even if you tweaked the settings to your desire. Future wicket versions will enable more features for developer productivity that will affect your users. Always tweak the DEPLOYMENT settings to make it more development like.


Read More

How to call Android contacts list and Display his name and Phone Number after selection?

Posted by in Android

There are three steps to this process.

1) Permissions

Add a permission to read contacts data to your application manifest.

2) Calling the Native Contact Picker

Android already has behavior built in to select contacts. This is used to select contacts for phone calls and other native apps. But it can also be used by apps like yours so you don’€™t have top build it yourself. Intents are a generic mechanism for invoking an action that the system can respond to. When the Android action code processed that Intent, it saw the reference to the Activity and invoked it directly. You don’€™t actually have to include a reference to an Activity in an Intent. You can also supply a Uri or a combination of Uri and an Action. And if you invoke the Intent, the Android action code looks for an Activity that responds to that Uri and invokes it.
 
** UPDATE: Android Complete tutorial now available here.
 
Within your Activity, create an Intent that asks the system to find an Activity that can perform a PICK action from the items in the Contacts URI.

Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);

Call startActivityForResult, passing in this Intent (and a request code integer, PICK_CONTACT in this example). This will cause Android to launch an Activity that’s registered to support ACTION_PICK on the People.CONTENT_URI, then return to this Activity when the selection is made (or canceled).

startActivityForResult(intent, PICK_CONTACT);

3) Listening for the Result

Also in your Activity, override the onActivityResult method to listen for the return from the ‘select a contact’ Activity you launched in step 2. You should check that the returned request code matches the value you’re expecting, and that the result code is RESULT_OK.

You can get the URI of the selected contact by calling getData() on the data Intent parameter.

When you print URI , it will be like this

08-10 15:44:52.131: DEBUG/Intent Data(355): content://com.android.contacts/contacts/lookup/0r1-512D45/1

To get the name of the selected contact you need to use that URI to create a new query and extract the name from the returned cursor.

@Override

public void onActivityResult(int reqCode, int resultCode, Intent data) {

super.onActivityResult(reqCode, resultCode, data);

switch (reqCode) {

case (PICK_CONTACT) :

if (resultCode == Activity.RESULT_OK) {

Uri contactData = data.getData();

Cursor c =  managedQuery(contactData, null, null, null, null);

if (c.moveToFirst()) {

String name = c.getString(c.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));

// TODO Whatever you want to do with the selected contact name.

}
}
break;
}
}

4 ) Display Phone Number

There is two steps to get Phone Number :

First we will get id for the selected contact through ContentResolver passing URI .
Second we will query ContentResolver for all phone numbers using android constant “ContactsContract.CommonDataKinds.Phone.CONTENT_URI” and adding where class through previous got id.

public void onActivityResult(int reqCode, int resultCode, Intent data) {

super.onActivityResult(reqCode, resultCode, data);

switch (reqCode) {

case (PICK_CONTACT) :

if (resultCode == Activity.RESULT_OK) {

Uri contactData = data.getData();
		Cursor contactCursor = getContentResolver().query(uri,
				new String[] { ContactsContract.Contacts._ID }, null, null,
				null);
		String id = null;
		if (contactCursor.moveToFirst()) {
			id = contactCursor.getString(contactCursor
					.getColumnIndex(ContactsContract.Contacts._ID));
		}
		contactCursor.close();
		String phoneNumber = null;
		Cursor phoneCursor = getContentResolver().query(
				ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
				new String[] { ContactsContract.CommonDataKinds.Phone.NUMBER },
				ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "= ? ",
				new String[] { id }, null);
		if (phoneCursor.moveToFirst()) {
			phoneNumber = phoneCursor
					.getString(phoneCursor
							.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
		}
		phoneCursor.close();

break;
}
}

  Read More

How to get a list of installed android applications in Android

Posted by in Android

Starting from the your Activity context you can obtain an instance of PackageManager through the method called  getPackageManager(). Using that class is it possible to get a list of ApplicationInfo objects containing details about apps such as MetaData, Permissions, Services or Activities.

Flag are very import for PackageManager .For example  PackageManager.GET_META_DATA will retrieve only meta data for all packages .

Useful data are for example the name of the app, the packageName used to retrieve additional information with PackageManager methods and the publicSourceDir that represent a simple way to identify system or user applications.
 
** UPDATE: Android Complete tutorial now available here.
 
Method 1:

final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = context.getPackageManager().queryIntentActivities( mainIntent, 0);

Method 2:

final PackageManager pm = getPackageManager();
//get a list of installed apps.
List packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);

for (ApplicationInfo packageInfo : packages) {
    Log.d(TAG, "Installed package :" + packageInfo.packageName);
    Log.d(TAG, "Launch Activity :" + pm.getLaunchIntentForPackage(packageInfo.packageName));
}

Method 3:Using ResolveInfo

private List getInstalledComponentList()
            throws NameNotFoundException {
        final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
        mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        List ril = getPackageManager().queryIntentActivities(mainIntent, 0);
        List componentList = new ArrayList();
        String name = null;

        for (ResolveInfo ri : ril) {
            if (ri.activityInfo != null) {
                Resources res = getPackageManager().getResourcesForApplication(ri.activityInfo.applicationInfo);
                if (ri.activityInfo.labelRes != 0) {
                    name = res.getString(ri.activityInfo.labelRes);
                } else {
                    name = ri.activityInfo.applicationInfo.loadLabel(
                            getPackageManager()).toString();
                }
                componentList.add(name);
            }
        }
        return componentList;
    }
Read More

SharePoint 2013 CAML Designer

Posted by in SharePoint, SharePoint 2013

 
SharePoint 2013 CAML query builder will be a great Tool for developers, it will help to build CAML query while using the Client Side Object Model in SharePoint 2013.

SharePoint 2013 CAML query builder with advanced features 2013 can be downloaded from the below link:


  Read More

Difference between minsdkversion and targetsdkversion

Posted by in Android

 

android:minSdkVersion

 
An integer designating the minimum API Level required for the application to run. The Android system will prevent the user from installing the application if the system’s API Level is lower than the value specified in this attribute. You should always declare this attribute.android:minSdkVersion helps Google Play filter apps for the user based on their device. For instance, with minSdkVersion=”7″, someone browsing with a device that only supports 6 won’t see your app on Google Play, and thus won’t download it, find it doesn’t work, and leave a bad review :)

 

android:targetSdkVersion

 
An integer designating the API Level that the application is targetting.

With this attribute set, the application says that it is able to run on older versions (down to minSdkVersion), but was explicitly tested to work with the version specified here. Specifying this target version allows the platform to disable compatibility settings that are not required for the target version (which may otherwise be turned on in order to maintain forward-compatibility) or enable newer features that are not available to older applications. This does not mean that you can program different features for different versions of the platform €”it simply informs the platform that you have tested against the target version and the platform should not perform any extra work to maintain forward-compatibility with the target version.

android:targetSdkVersion is a signal to the device about which version of the API your app was tested against. New behaviors are often available by default with new versions of the platform, for applications that target at least that version of the platform. For instance, by setting your targetSdkVersion to 11 or higher, you get an overflow menu in the ActionBar (for Honeycomb and up devices) instead of the “legacy menu button of shame”.

project.properties target is a signal to your local build system regarding which version of the platform you should be compiling your code against. Generally it’s best to just set this to whatever you have set for the targetSdkVersion.

 

android:maxSdkVersion

 
An integer designating the maximum API Level on which the application is designed to run.

In Android 1.5, 1.6, 2.0, and 2.0.1, the system checks the value of this attribute when installing an application and when re-validating the application after a system update. In either case, if the application’s maxSdkVersionattribute is lower than the API Level used by the system itself, then the system will not allow the application to be installed. In the case of re-validation after system update, this effectively removes your application from the device.

To illustrate how this attribute can affect your application after system updates, consider the following example:

An application declaring maxSdkVersion="5"in its manifest is published on Google Play. A user whose device is running Android 1.6 (API Level 4) downloads and installs the app. After a few weeks, the user receives an over-the-air system update to Android 2.0 (API Level 5). After the update is installed, the system checks the application’s maxSdkVersionand successfully re-validates it. The application functions as normal. However, some time later, the device receives another system update, this time to Android 2.0.1 (API Level 6). After the update, the system can no longer re-validate the application because the system’s own API Level (6) is now higher than the maximum supported by the application (5). The system prevents the application from being visible to the user, in effect removing it from the device.

You have to maintain backward compactiblity through your code:

In short, here is the purpose to declaring a different targetSDK from the minSDK: It means you are using features from a higher level SDK than your minimum, but you have ensured backwards compatibility. In other words, imagine that you want to use a feature that was only recently introduced, but that isn’t critical to your application. You would then set the targetSDK to the version where this new feature was introduced and the minimum to something lower so that everyone could still use your app.

To give an example, let’s say you’re writing an app that makes extensive use of gesture detection. However, every command that can be recognised by a gesture can also be done by a button or from the menu. In this case, gestures are a ‘cool extra’ but aren’t required. Therefore you would set the target sdk to 7 (“Eclair” when the GestureDetection library was introduced), and the minimumSDK to level 3 (“Cupcake”) so that even people with really old phones could use your app. All you’d have to do is make sure that your app checked the version of Android it was running on before trying to use the gesture library, to avoid trying to use it if it didn’t exist. (Admittedly this is a dated example since hardly anyone still has a v1.5 phone, but there was a time when maintaining compatibility with v1.5 was really important.)

To give another example, you could use this if you wanted to use a feature from Gingerbread or Honeycomb. Some people will get the updates soon, but many others, particularly with older hardware, might stay stuck with Eclair until they buy a new device. This would let you use some of the cool new features, but without excluding part of your possible market
 

Read More
Page 5 of 15«First...34567...10...Last»