Mobile Adapter - To Render Customer Visual Web Part in Mobile View

Suddenly requirement came like your site should be accessible on mobile, so started access sharepoint 2013 site on mobile.
 
On one non-publishing site , Custom web part was not rendering.
 
As it is non-publishing site render in Contemporary view
 
So to make webpart visible in mobile view , it needs mobile adapter
 
So following is the example:
 
Here is the webpart MyWebpart wanted to show on mobile view.

Create a class MyWebPartMobileAdapter derived from WebPartMobileAdapter.

Get instance of webpart as base control.

Override the CreateControlsForSummaryViewAdv method to add webpart to base controlsAlso as it is adapter so needs it's entry in \App_Browsers\compat.browser file of respective webapplication.
 
To add below entry could used powershell
 
 <adapter controlType="TestMobileAdapter.MyWebpart ,TestMobileAdapter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9edaaa10e3b0051e" adapterType="TestMobileAdapter.MyWebPartMobileAdapter,TestMobileAdapter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9edaaa10e3b0051e" />
 

using Microsoft.SharePoint.WebPartPages;

using System.Web.UI;

 

namespace TestMobileAdapter

{

    public class MyWebPartMobileAdapter: WebPartMobileAdapter

    {

        private const string _ascxPath = @"~/_CONTROLTEMPLATES/15/MyMobileAdapterControls/MyUserControl.ascx";

        private MyUserControl usercontrol;

 

// Get webpart instance , and set to base control

 

        protected new MyWebpart Control

        {

            get { return base.Control as MyWebpart ; }

        }      

 

        protected override void CreateControlsForSummaryViewAdv()

        {         

            usercontrol = Page.LoadControl(_ascxPath) as MyUserControl ;

            usercontrol.CacheTimeOut = Control.CacheTimeoutSeconds;

            usercontrol.PageSize = Control.PageSize;

            base.Controls.Add(usercontrol);

        }

    }

}