Unable to create a content type – A duplicate content type was found
I found my problem, so if this can help some people some day. Looks like SharePoint have some problems sometimes to update a field in the content database. The field NextChildByte from the dbo.ContentTypes table is the problem.
Lets say I create a content type with ID 0x010100ACEA2663B318874AA9192CA9AF678614 with Document as parent (0×0101). SharePoint will create an entry in the dbo.ContentTypes table.
When I create an other content type with the first one as parent.. The ID of this new content type will be 0x010100ACEA2663B318874AA9192CA9AF678614*01*) This 01 came from the NextChildByte field from the dbo. ContentTypes table. Now SharePoint should update the dbo.ContentTypes table and set the field NextChildByte to 2 so the next content type created using the same parent will be 0x010100ACEA2663B318874AA9192CA9AF678614*02*
My problem was.. SharePoint didnt update the NextChildByte field so SharePoint was trying to create a content type with ID 0x010100ACEA2663B318874AA9192CA9AF678614*01* when it already existed…
In my case.. I finally have been able to delete the content type 0x010100ACEA2663B318874AA9192CA9AF678614*01*. When I recreated it, SharePoint did update the NextChildByte to 2 so I was able to create a more child content type after that.
Unable to connect to sharepoint site
After successfull installation of TFS, when trying to create a new team project, first few steps completes, but then it says “unable to connect to sharepoint site” and stops.
In the server, Default Website is on port 80 : Displays sharepoint “Home”. Sharepoint admin is on port: 26442 : Displays “Sharepoint Central Admin”.
TFS is on port 8080: Displays “Access Forbidden”!! when directly browsed from http://servername:8080. The team explorer successfully connects to the TFS with the same username and password.
Solution
Steps:
1. Check the port number of Sharepoint Central Administration virtual directory. (For me, it was 26442)
2. Now, in IIS, browse Registration.asmx under ‘Services’ under “Team Foundation Server” virtual directory.
3. Click GetRegistrationEntries web service, without giving any parameter, click “Invoke”
4. In the resulting XML, search for
WssAdminService http://:17012/_vti_adm/admin.asmx
5. See “url” element, and the port number in that URL should be same as that in step 1.(For me it was 17012)
6. If not, change the port number of Sharepoint Central Administration to the one in the url in step 5. (17012)
The reason I understand is that if we are installing WSS SP1 or SP2 couple of times, it assigns different port numbers to the sharepoint admin vdir.
What is Context in Android
Context is context of current state of the application/object.Its an entity that represents various environment data . Context helps the current activity to interact with out side android environment like local files, databases, class loaders associated to the environment, services including system-level services, and more.
A Context is a handle to the system . It provides services like resolving resources, obtaining access to databases and preferences, and so on. An android app has activities. It’s like a handle to the environment your application is currently running in. The activity object inherits the Context object.
It lets newly created objects understand what has been going on. Typically you call it to get information regarding another part of your program (activity, package/application).
** UPDATE: Android Complete tutorial now available here.
According to Android Documentation
Interface to global information about an application environment. This is an abstract class whose implementation is provided by the Android system. It allows access to application-specific resources and classes, as well as up-calls for application-level operations such as launching activities, broadcasting and receiving intents, etc.
Different invoking methods by which you can get context
1. getApplicationContext(),
2. getContext(),
3. getBaseContext()
4. or this (when in the activity class).
Examples for uses of context:
1. Creating New objects: Creating new views, adapters, listeners
TextView tv = new TextView(getContext()); ListAdapter adapter = new SimpleCursorAdapter(getApplicationContext(), ...);
2. Accessing Standard Common Resources: Services like LAYOUT_INFLATER_SERVICE, SharedPreferences:
context.getSystemService(LAYOUT_INFLATER_SERVICE) getApplicationContext().getSharedPreferences(*name*, *mode*);
3. Accessing Components Implicitly: Regarding content providers, broadcasts, intent
getApplicationContext().getContentResolver().query(uri, ...);
You will need the Context class is when creating a view dynamically in an activity. For example, you may want to dynamically create a TextView from code (First Example). To do so, you instantiate the TextView class. The constructor for the TextView class takes a Context object, and because the Activity class is a subclass of Context, you can use the this keyword to represent the Context object.
A Context object provides access to the application’s resources and other features. Each Activity is a Context and each View needs a Context so it can retrieve whatever resources it needs (including things like system-defined resources).
Difference between Activity Context and Application Context:
They are both instances of Context, but the application instance is tied to the lifecycle of the application, while the Activity instance is tied to the lifecycle of an Activity. Thus, they have access to different information about the application environment.
If you read the docs at getApplicationContext it notes that you should only use this if you need a context whose lifecycle is separate from the current context.
But in general, use the activity context unless you have a good reason not to.
Need of Context :
The documentation says that every view needs the context to access the right resources (e.g. the theme, strings etc.).
But why in the constructor and not through setContentView(View)?
1.Because the resources must be accessible while the view is being constructed (the constructor will need some resources to fully initialise the view).
2.This allows the flexibility of using a context that is different from the one of the current activity (imagine a view that uses some other string resources and not the ones from the current activity).
3.The designers of the Android SDK seem to have chosen that the context must be set only once and then stay the same throughout the lifetime of the view.
Why context is not determined automatically at construction point?
1.Because there exists no static variable that would tell you the current global context of your application. The method getApplicationContext() is the closest to this, but it’s not static, so you need an instance of the Activity object to call it.
2.The Java language provides an option to look through the call stack and find whether the View has been constructed in a Context class. But what if there are many? Or what if there are none? This method is very expensive and error prone. So the designers of the API decided that a context must be manually provided.
Read More
Faster android emulation
It is fun to develop but not fun to test on emulator because of performance issues.
Here is what work for me after a long research ( information collected from internet source and books ). If you are running Windows 7 on an i5 processors then this might just work for you without getting into downloading virtual machine or any additional virtual images.
Hardware running on:
- i5 processor ( first generation , but any generation should do ).
- 3 GB main memory ( As per observation memory is not a constraint, anything more than 3 GB is enough on windows 7 )
Software :
- Android 20 SDK
- Windows 7 64-bit.
I have been into developing web application for mobile and wanted to test on android devices, it was not too late for me to realize that web application on the browsers on android is not any fast while my application works very fast on desktop browsers.
Here are the steps that made android emulator fast enough.
- Ensure your machine supports virtualization: Look into your bios settings and check if your system supports virtualization( latest intel based CPUs, mostly supports virtualization).
- Go to android SDK manager, Choose Extras->Intel x86 Emulator Acceleration ( HAXM) and install the package.
- Once installed from the SDK manager. Browse the path C:\Users\<Username>\AppData\Local\Android\android-sdk\extras\intel\Hardware_Accelerated_Execution_Manager.
- Click and install IntelHaxm.exe.
- Now open your Android virtual device manager. Its time to create a faster emulator.
- Click new , give it a name, choose target later than API level 18 ( earlier Levels will not work ) . Now the CPU/ABI is something we have to choose intel atom x86. And then choose your other preferences.
- Now start it.
With this you are ready to go. I tested the web application I was running on ARM CPU type and it made me search the web for solution. It was painfully slow.
Let me know if it works for you or if you face any issues
Read More
To Check Whether Internet Connection Available in Android
NetworkInfo class provides a non-static method isAvailable() which will return null if there no internet .
getActiveNetworkInfo() method of ConnectivityManager returns a NetworkInfo instance representing the first connected network interface it can find or null if it cant find any connected network. We could find whether internet connection is available by checking this method .
** UPDATE: Android Complete tutorial now available here.
Below code snippet will explain it .
private boolean doNetworkAvailable() { ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null && activeNetworkInfo.isConnectedOrConnecting(); }
In android manifest.xml , You have give following entry for permission.
Please Read It Carefully .
Return true from NetworkInfo doesn’t not guarantee that a particular networked service is available.
There are many other issue given below can prevent your app from reaching a server.
Networks issues,
server downtime
low signal
captive portals
content filters
To check it is connected mobile internet or WIFI
ConnectivityManagers getAllNetworkInfo() method returns list of NetworkInfo object . It contains NetworkInfo object of all possible network connection.
private boolean checkNetworkConnection() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo[] netInfo = cm.getAllNetworkInfo(); for (NetworkInfo simpleCode : netInfo) { if ("WIFI".equalsIgnoreCase(ni.getTypeName())) if (simpleCode.isConnected()) Toast.makeText(getApplicationContext(), "Network connected through WIFI", Toast.LENGTH_SHORT).show(); if ("MOBILE".equalsIgnoreCase(ni.getTypeName())) if (simpleCode.isConnected()) Toast.makeText(getApplicationContext(), "Network connected through Mobile Internet", Toast.LENGTH_SHORT).show(); } }
You can also use getType() (simpleCodes.getType() in previous example) instead getTypeName(), because getType() provides a finer level of granularity and might return one of TYPE_MOBILE, TYPE_WIFI, TYPE_WIMAX, TYPE_ETHERNET, TYPE_BLUETOOTH and so on .
TYPE_DUMMY – Dummy data connection.
TYPE_ETHERNET – The Default Ethernet data connection.
TYPE_MOBILE – The Default Mobile data connection.
TYPE_MOBILE_DUN – A DUN-specific Mobile data connection.
TYPE_MOBILE_HIPRI – A High Priority Mobile data connection.
TYPE_MOBILE_MMS – An MMS-specific Mobile data connection.
TYPE_MOBILE_SUPL – A SUPL-specific Mobile data connection.
TYPE_WIFI – The Default WIFI data connection.
TYPE_WIMAX – The Default WiMAX data connection.