Medium Feed

 

Monday, December 28, 2015

Application does not have sufficient geolocation permissions error - Cordova android hybrid app developement

Application does not have sufficient Geolocation permissions error  - Cordova android hybrid app development

I was getting this error while try to run my geolocation code in andorid device.

The reason was location access permission for the app is not enabled to app manifest.

Here's how to add the permission:

open your android manifest. xml file:

it will be in the location  : platforms\android\

and the below tag:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />

Then rebuild the app and run it .

It should work. !!!

Sunday, October 18, 2015

IoT Mobile Apps development using HTML 5 and Javascript

Recently, I came to know about an interesting framework called "Evothings" which makes developers life easy as to develop Mobile IoT applications just by using HTML 5 and JavaScript.
It helps developers to build  or connect with any bluetooth, BLE, Wifi , NFC devices just with little help of HTML 5 and Java script.
Evothings is a Sweden based startup and it is hyperload live mobile development feature is fantastic, it is makes developing and testing very easy. This framework comes with lot of working examples in connecting with different devices. And of-course it is open source apache 2 licensed framework.
It supports connectivity to many devices (working examples for each given)
To name few devices
Estimote beacons, Aurdino, Philips HUE light, Electric Imp, Rasberry pi,etc...

Monday, October 12, 2015

Apache cordova App - Change App icon or logo.

 To change the default icon or logo of an Cordova application. we just have to replace the default icon.png from the below folder icons and re-build the cordova app and then deploy it. 

For iOS:

PROJECT_PATH/platforms/ios/PROJECT_NAME/Resources/icons


For Android:

PROJECT_PATH/platforms/android/res/drawable

also you need to update the icon name change in manifest file.

PROJECT_PATH/platforms/android/AndroidManifest.xml

Friday, October 9, 2015

Cordova platform : " Error: Failed to run "ant -version", make sure you have ant installed and added to your PATH "

I was getting  below error while doing Cordova environment initial setup.

Few hours of wasting time in googling , have find out that the issue was "empty" space in the PATH.

So I changed  from C:\Program Files\... to C:\Progra~1\....

This fixed the issue and now when I run cordova platform add android command it executes successfully with out any errors.

Wednesday, October 7, 2015

Horizontal center align the Image inside the Div

If we have just text inside DIV , we can make that content center aligned just by giving "text-align:center". But in the case of having image inside the DIV and we wanted to make the image to be center aligned in DIV then "text-align:center" will NOT help.

Quick/ Easy fix is :

<div class="container>
<img  src="somthing.jpg" class="img">
</div>

<style>
.container { text-align:center;}
.img { display:inline; margin:0; padding:0}
</style>

Wednesday, September 16, 2015

How do I add a column (meta data) to SharePoint folders?

My first thought is to modify the Content Type named Folder, but it is "sealed". (Microsoft locked the door!) So I created a new Content Type based on Folder, added the custom column, added the content type to the library and magically I found my custom folder type in the New dropdown. Here's the steps:


  1. Go to Site ActionsSite Settings 
  2. Click Site Content Types 
  3. Click Create
  4. Give the new content type a name such as "Enhanced Folder" or "Product Spec Folder"
  5. Set the parent content type group as Folder Content Types
  6. Set the parent content type to Folder
  7. Add the new content type to a Group. I put it back in the "Folder Content Types" group
  8. Click OK
  9. Scroll down to the columns section and click Add from new site column
  10. Name the column and set all the usual column options
  11. Repeat for any additional columns (Release Date, etc)
  12. Click OK
  13. Go to your document library
  14. Click Settings and Library Settings, or in 2010 click the Library ribbon tab and then click Library Settings
  15. Click Advanced and set Allow management of content types to Yes and click OK (this may already selected)
  16. Scroll down to Content Types and click Add from existing site content types and add your new folder content type
  17. Go to your document library and click the New dropdown, or the New button in the 2010 Document ribbon, and add your new folder!
  18. Go to the View dropdown and click Modify this view and add your new folder meta data columns (you will probably want to move them to just after the Name column)

Monday, September 14, 2015

How to find Runtime version of a DLL

What is Runtime version: ?

Runtime version is the .Net framework version that the library was built against. 

We can be able to find runtime version of our custom DLL using assembly reflection:

Sample code:

 System.Reflection.Assembly myDll = System.Reflection.Assembly.ReflectionOnlyLoadFrom("C:\\mySolution.dll");
            Console.WriteLine(myDll.ImageRuntimeVersion);\


Tuesday, August 25, 2015

Send / Passing HTML Markup in SOAP XML as string

When we try to pass HTML markup as parameter string in SOAP XML, the SOAP request will get failed due to special characters / markups in the request XML.

I had faced this issue when I try to update SharePoint RichText list item using SharePoint web service post request.

Here's the code which was NOT working :

var soapEnv = "<?xml version=\'1.0\' encoding=\'utf-8\'?> \
<soap:Envelope xmlns:xsi=\'http://www.w3.org/2001/XMLSchema-instance\' \
xmlns:xsd=\'http://www.w3.org/2001/XMLSchema\' \
xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/\'> \
<soap:Body> \
<UpdateListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
<listName>MyListName</listName> \
<updates> \
<Batch OnError='Continue'> \
<Method ID='1' Cmd='Update'> \
<Field Name='ID'>1</Field> \
<Field Name='Desc'><div><strong>My  HTML markup content here  <br></strong></Field> \
</Method> \
</Batch> \
</updates> \
</UpdateListItems> \
</soap:Body> \
</soap:Envelope>";

if we post above SOAP xml , the webservice will throw error due to html markup in request XML.

To fix the above issue.

We can replace markup characters< with &lt;>with &gt; and & with &amp;.

         OR 

 We can use the easy way of using CDATA.

using CDATA , we can pass HTML markup placed inside SOAP xml request.

Here is the Working code:


  var soapEnv = "<?xml version=\'1.0\' encoding=\'utf-8\'?> \

<soap:Envelope xmlns:xsi=\'http://www.w3.org/2001/XMLSchema-instance\' \
xmlns:xsd=\'http://www.w3.org/2001/XMLSchema\' \
xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/\'> \
<soap:Body> \
<UpdateListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
<listName>MyListName</listName> \
<updates> \
<Batch OnError='Continue'> \
<Method ID='1' Cmd='Update'> \
<Field Name='ID'>1</Field> \
<Field Name='Desc'><![CDATA[<div><strong>My  HTML markup content here  <br></strong>]]></Field> \
</Method> \
</Batch> \
</updates> \
</UpdateListItems> \
</soap:Body> \
</soap:Envelope>";


Wednesday, June 17, 2015

Bootstrap toggle navigation bar not working in Mobile devices


We used bootstrap toggle/expansion navigation bar in our webpage and it was working well in all desktop browsers and also there is no issue even if we reduce browser size to mobile width.

But while we check in real mobile device browsers, the navigation bar not getting to toggle mode and still looks expanded like seeing in desktop browsers.

The problem was we missed to add the "viewport" tag in the html. :-)

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

we just added the viewport tage and now everything works perfect :-)

Sunday, May 17, 2015

Creating center positioned Master Page layout using CSS in SharePoint 2013

If we want to create a master page layout with all the contents or layouts center aligned . The simplest CSS trick which we can do is below:

Just add the below CSS in the your CSS file:

#s4-bodyContainer {padding-bottom: 0 !important; margin-left: 50px;
    margin-right: 50px; }
div.s4-title.s4-lp,
 body #s4-mainarea,
 #s4-topheader2,
 #s4-statusbarcontainer{
     margin: 50px;
     padding: 0px;
     float: none;
     background-image: none;
     background-color: white;
}


Also change the "s4-workspace" div like below:

<div id="s4-workspace" class="s4-nosetwidth">
...........

</div>


That is it ..  You are done !!!. :-)

Tuesday, April 21, 2015

Accessing Self execiting / anonymous functions objects from Ouside

As we all know the purpose of self execution function is to call setup codes automatically without any caller functions or event calls.

Here is the sample self execution function :

(function  (){
   function RamCool ()
     {
     alert  ('Cool');
      }
})();

In the above example we have created "RamCool " function inside the self executing function pattern and if you want to call that function from outside like below ..Your will get Error

function  (){
   function RamCool ()
     {
     alert  ('Cool');
      }
})();

<button id="sample " onclick="RamCool ();">

Because we can not make a call from outside to a function defined in self executed function pattern


SOLUTION:  How to handle this ?

We should follow the approach of Jquery library.  I mean we have to create as global variable or extend the existing global object.  Like below :

function  (){
  Var foe= function ()
     {
      }:

  foe.RamCool=function  (){
  alert ( ' Cool ' );
};
 return (window.foe=foe);
})();

<button id="sample " onclick="foe.RamCool ();">

Thats it !! You are done !. Now you should be able to "RamCool " from outside anywhere. 

Saturday, April 11, 2015

Analytics Google API Error 403: “User does not have any Google Analytics Account”

I had faced the below ERROR while programmatically accessing Google Analytics data.

Error : Analytics Google API Error 403: “User does not have any Google Analytics Account”


Reason;  The O2Auth API service account has not had read permission for the Google analytics account which we trying to integrate.

Resolution:  When we create a  02Auth API service account , it will give as API P12 key file and a Email address like "xxxxxxxxx-ntormu3hduj9lmaxxxxxx@developer.gserviceaccount.com"

This email address should be provided with read permission in our google analytics account:

To provide read permission, follow the below step:

> Login Google Service account
> Go to Admin section
> Click on User management
> Add the O2auth Service account email address and proivde read permission


You are Done !!!

Now your Google analytics Api code will work and you could read the google analytics data.

Friday, March 13, 2015

How to find a Channel ID in YouTube

If we wants to make an API request to get all the videos in the  particular Youtube channel, first we should have to collect the Channel ID for the channels which we are going to process in the API request.

Here is the simple step to get the Channel ID of a YouTube channel
> Go to the particular channel in You tube
> Click on view source from the browser
> Search for the embedded tag "data-channel-external-id" , this will gives the Channel ID.



Monday, March 9, 2015

Cross Domain API request using AJAX and JQuery

We often get into a requirement to read or post a data to an third party cross domain server through their exposed API’s.  We have plenty of straightforward options if we do it from the server side coding, but in the case of doing it from a client call we may get into “cross domain not allowed” error thrown by all browsers.

Here, will show you the one of the cross domain call approach using “JSONP”.

In this example I’m making GET request to Bright cove api  and getting response as JSONP:

NOTE: Using JSONP only we can do GET requests. POST requests is not possible.

<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<script>
(function() {
  var mediaAPI = "http://api.brightcove.com/services/library?callback=?";
  $.getJSON( mediaAPI, {
    command: "search_videos",
    video_fields: "videoStillURL,thumbnailURL,id,name",
    media_delivery: "http",
    token: "ZY4Ls9Hq6LCBgleGDTaFRDL..............",
    format: "jsonp"
  })
  .done(function( data,status ) {
alert(status);
 $.each(data, function(i, field){
        alert(data.items[0].name);
                
            });

  });
})();</script>
</body>
</html>

})();</script>
</body></html>

Tuesday, March 3, 2015

JSON to XML conversion : Error "This document already has a ' DocumentElement ' node"

 Today I had faced an  error while converting JSON string into an XML document object using JSON.net Jsonconvert.

Here is the code snippet

        FacebookClient fbclient = new FacebookClient();
        JObject objFeeb = JObject.Parse(@" " + fbclient.Get("me/feed") + " ");
        XmlDocument doc = JsonConvert.DeserializeXmlNode(objFeeb.ToString());


When I run the above code I was getting an error as  "This document already has a ' DocumentElement ' node"


To fix the issue, I  just have defined the root element of XML doc and it worked !!

Here is the working code.

  XmlDocument doc = JsonConvert.DeserializeXmlNode(objFeeb.ToString(), "FacebookFeed");

Monday, February 9, 2015

Visual Studio 2012 - Error message “No exports were found that match the constraint contract name”

Today I faced problem when I try to create a new project or opening an existing project in Visual Studio 2012.

The issue details:

I was getting the below error prompt when I tried to create new project in Visual Studio

Error message “No exports were found that match the constraint contract name...................”

After few hours of research and googling have solved this problem by clearing "ComponentModelCache" under app data.

Visual Studio 2012 users can found that folder from below location:

C:\Users\....\AppData\Local\Microsoft\VisualStudio\11.0\ComponentModelCache

Here just clear the contents/files inside the "ComponentModelCache" folder and restart the Visual Studio.

The issue solved !!!

Wednesday, February 4, 2015

Override Inline CSS Styles - HTML / CSS trick

Sometimes there is a need to override inline style with css. Good example might be the code where you don’t have an option to remove a markup , where finding a place where inline code is coming from might be a challenge.

Here is how you can override it. There are two elements involved in doing that:

  [style]   addition to existing css code
  !important  line in css code

<div class="FirstDiv" style="background: red;"> The inline styles for this div should make it red. </div>

You can overwrite/change the above in-line css by the below method

<style="text/css">

div[style].FirstDiv
{
background: green !important;
}