[GUIDE-DEV][HTC Sense SDK, Sense 4,5,6] How to build apps for HTC Sense

Search This thread

Nx Biotic

Senior Member
Oct 26, 2010
1,686
2,175
PA, USA
rgocal.github.io
Cant save the log in AIDE currently... but

uploadfromtaptalk1399151687653.jpguploadfromtaptalk1399151701670.jpguploadfromtaptalk1399151715889.jpg

Sent from my HTC One_M8 using Tapatalk
 

mikrosmile

Inactive Recognized Developer
Dec 13, 2011
1,245
3,336
Moscow
Cant save the log in AIDE currently... but

View attachment 2724062View attachment 2724064View attachment 2724065

Sent from my HTC One_M8 using Tapatalk

your Context is null. try this

Code:
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.prefs);
[B][COLOR="Red"]context = this;[/COLOR][/B]
SetupActionBar();
setTheme(getHtcThemeID(context, 3));
}

if this doesnt work, then getActivity();
 
  • Like
Reactions: Nx Biotic

Nx Biotic

Senior Member
Oct 26, 2010
1,686
2,175
PA, USA
rgocal.github.io
your Context is null. try this

Code:
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.prefs);
[B][COLOR="Red"]context = this;[/COLOR][/B]
SetupActionBar();
setTheme(getHtcThemeID(context, 3));
}

if this doesnt work, then getActivity();

We're golden, thanks man

Edit: If someone needs an HTC Preference activity for Sense 6, Source will be available on my git.

mehavupu.jpg


Sent from my HTC One_M8 using Tapatalk
 
Last edited:
  • Like
Reactions: Jonny

Nx Biotic

Senior Member
Oct 26, 2010
1,686
2,175
PA, USA
rgocal.github.io
How about would I implement a method where the app checks to see if its the correct HTC Sense version/device but if it isnt, just throws out a dialog saying for the user it isnt capadible with their device instead of getting a force close. Trying to see what I could do by the app looking in the /ect/sdk/sdkinfo.xml and checking for Sense version onCreate.

Edit: I see HTC Sense 6 apps with meta data in manifest saying Sense Version 6.0
Would this filter out devices on google play?

Sent from my HTC One_M8 using Tapatalk
 
Last edited:
May 8, 2014
43
29
Is it possible to get the resources for the Switch in Sense 6 UI?

I would like to integrate it in my app but do not want to use opensensesdk since it should be available on all devices.

Is there a possibility to get them?
 

mikrosmile

Inactive Recognized Developer
Dec 13, 2011
1,245
3,336
Moscow
Is it possible to get the resources for the Switch in Sense 6 UI?

I would like to integrate it in my app but do not want to use opensensesdk since it should be available on all devices.

Is there a possibility to get them?
Decompile com.htc.resources (From any Sense base rom) and get all you need
 
Last edited:
  • Like
Reactions: Exquisite Apps
May 8, 2014
43
29
Decompile com.htc.resources (From any Sense base rom) and get all you need

Sorry for writing again but I have a problem which you can hopefully solve.

I did as you said and decompiled com.htc.resources
After this I searched for a switch in the styles and found the following:

Code:
<style name="Widget.HTCDeviceDefault.CompoundButton.Switch" parent="@*android:style/Widget.DeviceDefault.CompoundButton.Switch">
        <item name="android:thumb">@drawable/switch_inner_holo_dark</item>
        <item name="android:track">@drawable/switch_track_holo_dark</item>
</style>

So I searched for the specific files:

switch_inner_holo_dark.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<selector
  xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false" android:drawable="@drawable/switch_thumb_disabled_holo_dark" />
    <item android:state_pressed="true" android:drawable="@drawable/switch_thumb_pressed_holo_dark" />
    <item android:state_checked="true" android:drawable="@drawable/switch_thumb_activated_holo_dark" />
    <item android:drawable="@drawable/switch_thumb_holo_dark" />
</selector>

switch_track_holo_dark
Code:
<?xml version="1.0" encoding="utf-8"?>
<selector
  xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true" android:drawable="@drawable/switch_bg_focused_holo_dark" />
    <item android:drawable="@drawable/switch_bg_holo_dark" />
</selector>

Then I copied over the specific files from the drawable folders and assign the styles to my switch like this:

Code:
<Switch xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tb_editMode"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:thumb="@drawable/switch_inner_holo_dark"
    android:track="@drawable/switch_track_holo_dark" />


But the Switch actually looks like the default android switch. Did I oversee something? Actually the resources which I copied over looks like this so I don't think I get the right resources.

Any help appreciated.
 

mikrosmile

Inactive Recognized Developer
Dec 13, 2011
1,245
3,336
Moscow
Sorry for writing again but I have a problem which you can hopefully solve.

I did as you said and decompiled com.htc.resources
After this I searched for a switch in the styles and found the following:

Code:
<style name="Widget.HTCDeviceDefault.CompoundButton.Switch" parent="@*android:style/Widget.DeviceDefault.CompoundButton.Switch">
        <item name="android:thumb">@drawable/switch_inner_holo_dark</item>
        <item name="android:track">@drawable/switch_track_holo_dark</item>
</style>

So I searched for the specific files:

switch_inner_holo_dark.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<selector
  xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false" android:drawable="@drawable/switch_thumb_disabled_holo_dark" />
    <item android:state_pressed="true" android:drawable="@drawable/switch_thumb_pressed_holo_dark" />
    <item android:state_checked="true" android:drawable="@drawable/switch_thumb_activated_holo_dark" />
    <item android:drawable="@drawable/switch_thumb_holo_dark" />
</selector>

switch_track_holo_dark
Code:
<?xml version="1.0" encoding="utf-8"?>
<selector
  xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_focused="true" android:drawable="@drawable/switch_bg_focused_holo_dark" />
    <item android:drawable="@drawable/switch_bg_holo_dark" />
</selector>

Then I copied over the specific files from the drawable folders and assign the styles to my switch like this:

Code:
<Switch xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tb_editMode"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:thumb="@drawable/switch_inner_holo_dark"
    android:track="@drawable/switch_track_holo_dark" />


But the Switch actually looks like the default android switch. Did I oversee something? Actually the resources which I copied over looks like this so I don't think I get the right resources.

Any help appreciated.

I don't think you found the right switch resources. The name should be HtcSwitch and not the Compound.Switch.

I'll look tomorrow for this, as I did the resource implementation without libs approximately last year

Sent from my HTC One_M8 using Tapatalk
 
  • Like
Reactions: Exquisite Apps
May 8, 2014
43
29
I don't think you found the right switch resources. The name should be HtcSwitch and not the Compound.Switch.

I'll look tomorrow for this, as I did the resource implementation without libs approximately last year

Sent from my HTC One_M8 using Tapatalk


That would be really great if you would do that. I will look again and try to find it.

Will write if I found it.
Thanks.
 

Nx Biotic

Senior Member
Oct 26, 2010
1,686
2,175
PA, USA
rgocal.github.io
I see HTC Sense 6 apps with meta data in manifest saying Sense Version 6.0
Would this filter out devices on google play?

Just wanted to confirm this is the solution if you plan on releasing Sense 6 apps on playstore. Just check out Blinkfeed's manifest for Sense 6 meta data and add it to your manifest and it filters out every device except HTC Sense 6 powered devices on Google Play.



Sent from my HTC One_M8 using Tapatalk
 
  • Like
Reactions: fisha21

Nx Biotic

Senior Member
Oct 26, 2010
1,686
2,175
PA, USA
rgocal.github.io
Now to figure out how to apply the HTC theme to a layout like in Blinkfeed and we pretty much got everything down.

Edit:Apparently this is called a HTC Masthead?

Achieving this would make great material ui app concepts for Sense.
zugape2u.jpg

u9eta3y3.jpg
 
Last edited:

mikrosmile

Inactive Recognized Developer
Dec 13, 2011
1,245
3,336
Moscow
Updates to SlidingMenu.

Code:
 mSlidingMenu.setFadeEnabled(true);
- add this to enable Fading effect. when you closing it, the behind will be darker (like File manager)


Code:
mSlidingMenu.setMode(0);
- mode 0 is left, mode 1 is right.
 
  • Like
Reactions: fisha21

Top Liked Posts

  • There are no posts matching your filters.
  • 16
    Complete GUIDE to develop an application using HTC OpenSense SDK

    Requirements:
    1. Eclipse
    2. Basic knowledge of Android App Development. I will not explain basic things (Like making activity, listview and etc)
    3. HTC OpenSense SDK Installed - See post 4 How to add Reference Library
    4. HTC Phone with HTC Sense. Not For AOSP ROMs

    Create Project with OpenSense SDK
    Create new project. Name it as you want. These are requirements. Other you can state as you want
    • Minimum Required SDK - 15
    • Target SDK - >= 19 (or older is 16)
    • Compile with - HTC OpenSense API 19 (or older is 16)
    • Theme - Holo Light with dark action bar
    • Create activity - Blank
    • Navigation type - None

    Check if SDK is choosen correctly
    In your project in Android Dependencies should be HTCExtension.jar file
    Above Android Dependencies should be stated which SDK api you are using. HTC OpenSense APIs [Android 4.4.2] (or older is 4.1.2)

    You can start building your application with HTC OpenSense SDK.

    Guide content:











    If I helped you to create your first Application using HTC OpenSense SDK simply rate thread and hit thanks button, give credits and link to this Thread. If you are brave enought to admitt that this thread is helped you.
    In any case Im doing it to help you to learn more
    7
    Add HTC Sense Skin support.

    In AndroidManifest add this line inside <application tag and before first <activity tag where you have your MainActivity

    Code:
    <application
            [COLOR="Red"]allowSkinChange="true"[/COLOR]
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name="com.yourpackage.name.MainActivity"

    There will be Error in Manifest, says "Attribute is missing the Android namespace prefix"

    It is fine, to fix it go to - Project -> Clean; Choose your Application and click Ok​

    Add reference library to use full HTC app experience
    Sense 6
    Download this package - View attachment addon-htc_opensense_apis-htc-19.zip
    Place the extracted folder to <location of android SDK>\android\sdk\add-ons\
    Choose HTC OpenSense SDK 19 when you start building your application. Profit

    Sense 5 and below
    Refer to this, thanks to Jonny
    Make sure HTCExtension lib is appear in your Eclipse project​


    Use HTCPreference Activity
    Htc Preference is the same as normal Preference but you need to follow some rules when you want to have this.

    First in your Preference activity (for example you already have one) change PreferenceActivity to HtcPreferenceActivity.

    import com.htc.preference.*;

    In prefs.xml (or any other xml file you have your preferences in) make sure everything is using this way

    This is original android way.
    <PreferenceScreen> </PreferenceScreen>

    This is Htc way
    <com.htc.preference.HtcPreferenceScreen> </com.htc.preference.HtcPreferenceScreen>

    So basically to every single item in preferences you need to add com.htc.preference.Htc****


    Here is prefs.xml example

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <[COLOR="Red"]com.htc.preference.Htc[/COLOR]PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
        <[COLOR="red"]com.htc.preference.Htc[/COLOR]CheckBoxPreference
            android:title="@string/load_icons"
                android:summary="@string/load_icons_summary"
                android:defaultValue="true"
                android:key="show_dialog">
            </[COLOR="red"]com.htc.preference.Htc[/COLOR]CheckBoxPreference>
            <[COLOR="red"]com.htc.preference.Htc[/COLOR]SwitchPreference
                android:title="@string/load_skins"
                android:summary="@string/load_skins_summary"
                android:switchTextOn="@string/on"
                android:switchTextOff="@string/off"
                android:defaultValue="true"
                android:key="skins_on_start">
            </[COLOR="red"]com.htc.preference.Htc[/COLOR]SwitchPreference>
    
    </[COLOR="red"]com.htc.preference.Htc[/COLOR]PreferenceScreen>


    This is how Pref activity should be

    Code:
    package com.yourpackage.name;
    
    import android.os.Bundle;
    import android.view.View;
    
    import com.htc.widget.ActionBarContainer;
    import com.htc.widget.ActionBarExt;
    import com.htc.widget.ActionBarText;
    [COLOR="red"]import com.htc.preference.*;[/COLOR]
    
    public class Settings extends [COLOR="red"]Htc[/COLOR]PreferenceActivity  {
    	private ActionBarExt actionBarExt=null;
    	private ActionBarText actionBarText=null;    
    	private ActionBarContainer actionBarContainer=null;
    	
    	private void SetupActionBar() {
            actionBarExt=new ActionBarExt(this,getActionBar());
            actionBarExt.enableHTCLandscape(false);
            actionBarContainer=actionBarExt.getCustomContainer();
            actionBarText=new ActionBarText(this);    		        
    	    actionBarText.setPrimaryText(R.string.settings);   
    	    actionBarContainer.addCenterView(actionBarText);
    		actionBarContainer.setRightDividerEnabled(true);
        } 
    
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		// TODO Auto-generated method stub
    		super.onCreate(savedInstanceState);
    			addPreferencesFromResource(R.xml.prefs);
    		} 
    		
    		SetupActionBar();
    	}
    
    }

    If you cannot import com.htc.preference.*; (Eclipse will give you error) it means you dont have HtcExtension lib. Make sure you added it before doing this.

    6
    HTC Carousel Activity/Fragment (Swipeable tabs) - Sense 3.6 up to Sense 6 Samples
    HTC Carousel with Tabs for Sense 3.6 up to Sense 4 (Using Activities)
    Create classes and Carousel (HTC Sense Tabs)

    Create simple activities
    • Create two classes Tab1.java; Tab2.java
    • Create two layout xml files - tab_1.xml; tab_2.xml;
    • Place any two different png icons for Tab1 and Tab2 reference

    tab_1.xml
    Code:
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
     >
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="This is Tab1" />
    
    </RelativeLayout>

    tab_2.xml
    Code:
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
     >
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="This is Tab2" />
    
    </RelativeLayout>

    Tab1.java
    Code:
    package com.yourpackage.name;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    public class Tab1 extends Activity {
    	
                      [user=439709]@override[/user]
    	protected void onCreate(Bundle savedInstanceState) {
    		// TODO Auto-generated method stub
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.tab_1);
    	}
    	
    
    }

    Tab2.java
    Code:
    package com.yourpackage.name;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    public class Tab2 extends Activity {
    	
                      [user=439709]@override[/user]
    	protected void onCreate(Bundle savedInstanceState) {
    		// TODO Auto-generated method stub
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.tab_2);
    	}
    	
    
    }

    Create carousel (HTC Sense Tabs) and put tabs together

    Create class: TabProvider.java; Remove everything inside class and place this code:

    com.yourpackage.name - it is your name of package.

    TabProvider.java
    Code:
    package com.yourpackage.name;
    
    import com.htc.content.CarouselProvider;
    
                      [user=1299008]@supp[/user]ressWarnings("deprecation")
    public class TabProvider extends CarouselProvider {
        final static String AUTHORITY =
          "com.yourpackage.name.TabProvider";
    
        public TabProvider() {
            super();
            setupCarousel(AUTHORITY);
    
        }
    
    }

    Open MainActivity, remove everything from class and paste this code:

    MainActivity.java
    Code:
    package com.yourpackage.name;
    
    import android.content.Intent;
    import android.os.Bundle;
    import com.htc.widget.CarouselActivity;
    import com.htc.widget.CarouselHost;
    
    public class MainActivity extends CarouselActivity {
    	final static String AUTHORITY =
    			"com.yourpackage.name.TabProvider";
    
        public MainActivity() {
            super(AUTHORITY);
        }
        
    
                      [user=439709]@override[/user]
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		this.setGId(1);
            super.onCreate(savedInstanceState);
            final CarouselHost mPanelHost = getCarouselHost();
            
            mPanelHost.addTab("Tab1", this, R.string.tab_1,
                    R.drawable.ic_tab1,
                    R.drawable.ic_tab1,
                    R.drawable.ic_tab1, 
                        (new Intent("com.yourpackage.name.Tab1")));
       mPanelHost.addTab("Tab2", this, R.string.tab_2,
                    R.drawable.ic_tab2,
                    R.drawable.ic_tab2,
                    R.drawable.ic_tab2, 
                        (new Intent("com.yourpackage.name.Tab2"))); 
    	}
    
    
    }

    Configuring manifest
    Dont forget, all classes have to be in Manifest.

    Code:
    <activity
                android:name=".Tab1"
                android:screenOrientation="portrait"
                android:configChanges="orientation"
                android:label="Tab1" >
                <intent-filter>
                <action android:name="com.yourpackage.name.Tab1" />
                <category android:name="android.intent.category.DEFAULT" />
                </intent-filter>
            </activity>
    <activity
                android:name=".Tab2"
                android:screenOrientation="portrait"
                android:configChanges="orientation"
                android:label="Tab2" >
                <intent-filter>
                <action android:name="com.yourpackage.name.Tab2" />
                <category android:name="android.intent.category.DEFAULT" />
                </intent-filter>
            </activity>

    Also for HTC SDK you have to state Provider: Create provider at the end of Manifest before </application> tag

    Code:
    <provider
                android:name="com.yourpackage.name.TabProvider"
                android:authorities="com.yourpackage.name.TabProvider" />


    Create ActionBar in HTC Sense Style

    For all tabs in your main activity you dont need to create actionbar for each of them, you need only one Actionbar for all Tabs.
    That means all Activities which will be part of TabCarousel it will use the same action bar from MainActivity.

    Make Changes in your mainactivity as follow:

    MainActivity.java with ActionBar
    Code:
    package com.yourpackage.name;
    
    import android.content.Intent;
    import android.os.Bundle;
    import com.htc.widget.CarouselActivity;
    import com.htc.widget.CarouselHost;
    [COLOR="Red"]import com.htc.widget.ActionBarExt;
    import com.htc.widget.ActionBarText;[/COLOR]
    
    public class MainActivity extends CarouselActivity {
    	final static String AUTHORITY =
    			"com.yourpackage.name.TabProvider";
            [COLOR="red"]public static ActionBarText mActionText;[/COLOR]
    
        public MainActivity() {
            super(AUTHORITY);
        }
    
    [COLOR="red"] private void SetupActionBar()
        {
            Object obj = new ActionBarExt(this, getActionBar());
            ((ActionBarExt)obj).setFullScreenEnabled(true);
            ((ActionBarExt)obj).enableHTCLandscape(false);
            mActionText = new ActionBarText(this);
            mActionText.setPrimaryText(R.string.app_name);
            obj = ((ActionBarExt)obj).getCustomContainer();
            ((ActionBarContainer)obj).setRightDividerEnabled(true);
            ((ActionBarContainer)obj).addCenterView(mActionText);
        }[/COLOR]
        
    
                      [user=439709]@override[/user]
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		this.setGId(1);
            super.onCreate(savedInstanceState);
            final CarouselHost mPanelHost = getCarouselHost();
            [COLOR="red"]SetupActionBar();[/COLOR]
            
            mPanelHost.addTab("Tab1", this, R.string.tab_1,
                    R.drawable.ic_tab1,
                    R.drawable.ic_tab1,
                    R.drawable.ic_tab1, 
                        (new Intent("com.yourpackage.name.Tab1")));
       mPanelHost.addTab("Tab2", this, R.string.tab_2,
                    R.drawable.ic_tab2,
                    R.drawable.ic_tab2,
                    R.drawable.ic_tab2, 
                        (new Intent("com.yourpackage.name.Tab2"))); 
    	}
    
    
    }

    HTC Carousel with Tabs for Sense 4.1 up to Sense 5.5 (Using Fragments)
    Create Carousel Fragment, Tabs, MainActivity

    Create Tab Fragments
    Now instead of Activities we will use Fragments, and it is difficult for some users. And I will try to explain how to build Carousel and not how to build Fragment Activity. But as example you can refer to my Open Source project myStore (which now converted to Fragments)

    Create two classes Tab1Fragment and Tab2Fragment

    Tab1Fragment.java

    Code:
    package your.package.name;
    
    [COLOR="Lime"]#2[/COLOR] import android.app.Fragment;
    
    [COLOR="lime"]#1[/COLOR] public class Tab1Fragment [B][COLOR="red"]extends Fragment[/COLOR][/B] {
    Button button;
    
    [COLOR="lime"]#3[/COLOR] public Tab1Fragment () {      
        }
    
    [COLOR="lime"]#4[/COLOR]     [user=439709]@override[/user]  
        public [B][COLOR="Red"]View onCreateView[/COLOR][/B](LayoutInflater inflater, ViewGroup container,  
                                 Bundle savedInstanceState) { 
                                 View view =  inflater.inflate(R.layout.tab1, container, false);
                                [COLOR="Lime"]#7[/COLOR] button = (Button) [B][COLOR="Red"]view.[/COLOR][/B]findViewById(R.id.button);
                                [COLOR="RoyalBlue"][I]//All your code that you need when application is first time created (see onCreate method example)[/I][/COLOR]
    
                              [COLOR="lime"]#5[/COLOR]   [B][COLOR="red"]return view;[/COLOR][/B]
             }
    
    [COLOR="lime"]#6[/COLOR]
        }

    As you can see the Class structure is different from what you might get used.
    Now you need to extend class as Fragment (#1) and import android.app.Fragment; (#2)
    Then you need to have public method which represent the entire Class with the name of the Class (#3)
    And Fragment uses onCreateView method instead of onCreate in Activity (#4)
    And you also need return statement for the view (#5) which will be at the end after all your code inside onCreateView method
    Outside onCreateView you will have all your methods for the purpose of application and those methods you will call from onCreateView method.
    Example of (#7) is that how you need to use findViewById method. you need to add view. before the method. Other than tha is the same

    Now create Tab2Fragment and use the same method but different layout resources.


    Create Tab Provider

    Code:
    package your.package.name;
    
    import com.htc.fragment.content.CarouselProvider;
    
    public class TabProvider extends CarouselProvider {
    	public TabProvider(){
            super();
            setupCarousel(MainActivity.AUTHORITY);
        }
    
    }


    Create CarouselFragment
    Now to store tabs in your application we will use separate Carousel class where you will identify each tab, name, Class, icons , etc
    For each tab create method for it for example

    Code:
    private void addTab1(CarouselHost host, String tag, int icon, int str) {
            host.addTab(getActivity(), new CarouselTabSpec(tag,
                    str, icon, icon, icon, Tab1Fragment.class.getName()));
        }
    
    private void addAnotherTab(CarouselHost host, String tag, int icon, int str) {
            host.addTab(getActivity(), new CarouselTabSpec(tag,
                    str, icon, icon, icon, AnotherTabFragment.class.getName()));
        }

    and in onActivityCreated method add your tab as in example

    Code:
    addAnotherTab(host, "AnotherTab", R.drawable.another_icon,
                    R.string.another_tab);


    Carousel.java

    Code:
    package your.package.name;
    
    import android.os.Bundle;
    
    import com.htc.fragment.widget.CarouselFragment;
    import com.htc.fragment.widget.CarouselHost;
    import com.htc.fragment.widget.CarouselTabSpec;
    
    public class Carousel extends CarouselFragment {
    
    	public Carousel() {
    		super(MainActivity.AUTHORITY);
    		requestCarouselFeature(CarouselFragment.FEATURE_CUSTOM_TITLE);
    	}
    
    	private void addTab1(CarouselHost host, String tag, int icon, int str) {
            host.addTab(getActivity(), new CarouselTabSpec(tag,
                    str, icon, icon, icon, Tab1Fragment.class.getName()));
        }
    
    	private void addTab2(CarouselHost host, String tag, int icon, int str) {
            host.addTab(getActivity(), new CarouselTabSpec(tag,
                    str, icon, icon, icon, Tab2Fragment.class.getName()));
        }
    	
    
         [user=439709]@override[/user]
        public void onActivityCreated(Bundle savedInstanceState) {
            super.onActivityCreated(savedInstanceState);
    
            final CarouselHost host = getCarouselHost();
    
            addTab1(host, "Tab1", R.drawable.ic_tab1,
                    R.string.tab1);
            addTab2(host, "Tab2", R.drawable.ic_tab2,
                    R.string.tab2);
    	}
    	
    }


    Create MainActivity
    Now MainActivity will be simple Activity with reference to Carousel class.

    Code:
    package your.package.name;
    
    public class MainActivity extends Activity {
    	final static String AUTHORITY = "your.package.name.MainActivity";
    	private Carousel mCarousel = null;
    
    
    public void onCreate(Bundle savedInstanceState) {
            requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
            final int rootId = 1;
            FrameLayout viewRoot = new FrameLayout(this);
            viewRoot.setId(rootId);
            setContentView(viewRoot);
            mCarousel = new Carousel();
            FragmentTransaction ft = getFragmentManager().beginTransaction();
            ft.add(rootId, mCarousel);
            ft.commit();
            registerForContextMenu(viewRoot);
         }
    }


    Configuration of Manifest

    For Fragments you dont need anymore to add permission for them in Manifest (Only for Activities)

    So basically with One mainactivity and two Tabs your manifest should look like

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="your.package.name"
        android:versionCode="10"
        android:versionName="1.0" >
    
        <uses-sdk
            android:minSdkVersion="15"
            android:targetSdkVersion="17" />
    
        <application
            android:allowBackup="true"
            allowSkinChange="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name="your.package.name.MainActivity"
                android:screenOrientation="portrait"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <provider
                android:name="your.package.name.TabProvider"
                android:authorities="your.package.name.MainActivity" />
        </application>
    
    </manifest>

    Make sure your provider is exaclty as follow.​

    HTC Carousel with Tabs for Sense 6 (Using Fragments)

    Create CarouselFragment, MainActivity, Tabs

    CarouselFragment:
    Code:
    package com.your.pkg;
    
    [COLOR="red"]import com.htc.fragment.widget.CarouselFragment; <!-- Make sure the imports from com.htc.fragment.*-->
    import com.htc.fragment.widget.CarouselHost;
    import com.htc.fragment.widget.CarouselTabSpec;[/COLOR]
    
    importcom.your.pkg.MainActivity;
    import com.your.pkg.R;
    import android.os.Bundle;
    
    
    public class Carousel extends [COLOR="Red"]CarouselFragment[/COLOR] {
    	
    	public Carousel() {
    		super(MainActivity.AUTHORITY);
    		requestCarouselFeature(CarouselFragment.FEATURE_CUSTOM_TITLE);
    		
    		
    	}
    	
    
    	private void addTab(CarouselHost host, String tag, int icon, int str, String tag5) {
            host.addTab(getActivity(), new CarouselTabSpec(tag,
                    str, tag5));
            
        }
    public void onActivityCreated(Bundle savedInstanceState) {
    	        super.onActivityCreated(savedInstanceState);
    
    	        final CarouselHost host = getCarouselHost();
    
    	        addTab(host, [COLOR="Blue"]"FirstTab"[/COLOR], R.drawable.ic_launcher,
    	               R.string.[COLOR="Blue"]first[/COLOR], First.class.getName());
    
    	        addTab(host, [COLOR="Blue"]"SecondTab"[/COLOR], R.drawable.ic_launcher,
    		               R.string.[COLOR="Blue"]second[/COLOR], Second.class.getName());
    	        
                    [COLOR="Red"]<!-- Add as many addTab(); methods as you need Tabs. The addTab() is universal-->[/COLOR]
    
    		}
    }

    MainActivity
    Code:
    public class MainActivity extends MfMainActivity {
    	public final static String AUTHORITY = "mikrosmile.kontrol.MainActivity";
    
    private Carousel mCarousel = null;
    static Window window;
    
    @Override
    	protected void onCreate(Bundle savedInstanceState) {
                    requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    		super.onCreate(savedInstanceState);
    
            final int rootId = 1;
            FrameLayout viewRoot = new FrameLayout(this);
            viewRoot.setId(rootId);
            setContentView(viewRoot);
            mCarousel = new Carousel();
            FragmentTransaction ft = getFragmentManager().beginTransaction();
            ft.add(rootId, mCarousel);
            ft.commit();
            registerForContextMenu(viewRoot);
            getWindow().setFormat(1);
    
    }
    
    }

    Tabs
    Code:
    Any Activity or Fragment

    HTC's Release to Refresh method (Swipe2Refresh)

    The Release to Refresh is like this:
    View attachment 2711413

    It can be added to any View. I will show example how to add it to ListView
    Code:
    [COLOR="red"]import com.htc.widget.OnPullDownListener;[/COLOR]
    public static ActionBarRefresh aRefresh;
    
    
    @Override
    	protected void onCreate(Bundle bundle) {
    //Adding inside onCreate method of you listActivity
    list.[COLOR="Red"]setOnPullDownListener(new PullDown());[/COLOR]
    
    }
    
    
    public class PullDown implements OnPullDownListener{
    //just a class inside your listActivity
    
    @Override
    		public void onGapChanged(int top, int bottom) {
    			if(top != 0){
    					actionbarext.getCustomContainer().setRotationMax(top); 
    					 actionbarext.getCustomContainer().setRotationProgress(bottom);
    				         //actionbarext.getCustomContainer is your ActionBar container
    			}
    		}
    
                    @Override
    		public void onPullDownCancel() {
    				 actionbarext.getCustomContainer().setUpdatingState(0);
    		}
    
                    @Override
    		public void onPullDownRelease() {
    			actionbarext.getCustomContainer().setUpdatingState(0);
                            //do whatever you need to update the list here, you can call a method or AsyncTask from here
    			
    		}
    
                   @Override
    		public void onPullDownToBoundary() {
    				actionbarext.getCustomContainer().setRotationProgress(actionbarext.getCustomContainer().getRotationMax());
    		}
    
    }

    Code:
    On your method to update list add this to onPreExecute
    
                    aRefresh.setVisibility(View.VISIBLE);
    		aRefresh.setPrimaryText("Updating...");
    		actionbartext.setPrimaryVisibility(View.GONE);
    		actionbartext.setSecondaryVisibility(View.GONE);
    
    
    When you finish your task to update list, inside onPostExecute add this 
    
    actionbarext.getCustomContainer().setUpdatingState(0);

    Code:
    Inside your method to SetupActionBar add this 
    
                    aRefresh = new ActionBarRefresh(c);
    		aRefresh.setVisibility(View.GONE);
                    actionbarext.getCustomContainer().addCenterView(aRefresh);


    Add HTC Sense 6 Theme support to your app


    Inside your MainActivity add this method


    Code:
    public static int getHtcThemeID(Context context, int i)
        {
        	return HtcWrapConfiguration.getHtcThemeId(context, i);
            
        }


    And in onCreate method add this

    Code:
    setTheme(getHtcThemeID(context, 0));

    This method is returning current Choosen theme ID by Variable from 0 to 3.
    So, when you open Personalization - Theme. You see 4 Themes. First 3 has different Color boxes at the top. The first 3 is the actual variable integer from 0 - 3.

    So, if you want to get , let's say Red color from Theme 2. You have to Choose Theme 2 in the Theme Settings, and in the app use this:

    Code:
    setTheme(getHtcThemeID(context, 3));

    Once you change Theme, it will also use The Orange color from Theme 1, and the Purple Color from Theme 3



    Add SlidingMenu to your Sense application

    To make the sliding menu in your application like Mail app or File manager app, follow this:
    View attachment 2876504

    Code:
    public class MainActivity extends [COLOR="Red"]SlidingActivity [/COLOR]{
    [COLOR="red"]private SlidingMenu mSlidingMenu;[/COLOR]
    
    public void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		window = getWindow();
    		setContentView(R.layout.activity_main);
    		[COLOR="red"]setBehindContentView(R.layout.activity_behind);
    		initSlidingMenu();[/COLOR]
    		SetupActionBar(this);
    
    	}
    
         private void initSlidingMenu()
        {
    		mSlidingMenu = getSlidingMenu();
    		[COLOR="red"]mSlidingMenu.setBehindWidth(500);[/COLOR] [COLOR="Lime"]//any width as you want[/COLOR]
                    mSlidingMenu.setFadeDegree(0.5F);
                    mSlidingMenu.setFadeEnabled(true);
                    mSlidingMenu.setMode(0);
                    mSlidingMenu.setTouchModeAbove(0);
                    mSlidingMenu.setOnOpenedListener(new com.htc.widget.SlidingMenu.OnOpenedListener() {
    
    
                public void onOpened()
                {
                    initSlidingMenuContent();
                }
            });
        }
    
    private void initSlidingMenuContent(){
    		[COLOR="red"] mSlidingMenu.setShadowWidth(50);
                     mSlidingMenu.setShadowDrawable(ICservices.getShadowDrawable());[/COLOR][COLOR="Lime"]//any shadow drawable you want
    //here is all your code that represent the behind layout. it can be listview or any other View you need[/COLOR]
    	}
    
    
    [COLOR="SeaGreen"]//if you want to have a toggle at the actionbar, also add OnClickListener to ActionbarTextView and add IconView to Actionbar[/COLOR]
    
    }
    
    add this permission to Manifest:
    [COLOR="red"]<uses-permission android:name="com.htc.permission.APP_DEFAULT" />[/COLOR]
    4
    Add 3 Dot menu to actionbar
    For the Menu in actionbar you just implement simple menu method, but you dont need to use menu.xml for it.
    Also you dont need to create string values for Menu, it will generate automatically for you, the icon, and the name.

    This is method to create Menu in ActionBar. Add it in MainActivity before SetupActionBar() method

    Code:
    public void onCreateContextMenu (ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
            super.onCreateContextMenu(menu, v, menuInfo);
            menu.add("ContextMenu");
        }
        
                         [user=439709]@override[/user]
        public boolean onCreateOptionsMenu (Menu menu) {
            menu.add(1, 1, 1, R.string.settings);
            return true;
        }
        
        public boolean onOptionsItemSelected(MenuItem menuitem)
        {
        	boolean flag = true;
            switch (menuitem.getItemId())
            {
            case 1:
            	startActivity(new Intent(this, Settings.class));
            	break;
            }
            return flag;
        	
        }

    This is your new MainActivity with Menu

    Code:
    package com.yourpackage.name;
    
    import android.content.Intent;
    import android.os.Bundle;
    import com.htc.widget.CarouselActivity;
    import com.htc.widget.CarouselHost;
    import com.htc.widget.ActionBarExt;
    import com.htc.widget.ActionBarText;
    [COLOR="Red"]import android.view.ContextMenu;
    import android.view.Menu;
    import android.view.MenuItem;[/COLOR]
    
    public class MainActivity extends CarouselActivity {
    	final static String AUTHORITY =
    			"com.yourpackage.name.TabProvider";
            public static ActionBarText mActionText;
    
        public MainActivity() {
            super(AUTHORITY);
        }
    
    [COLOR="red"]public void onCreateContextMenu (ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
            super.onCreateContextMenu(menu, v, menuInfo);
            menu.add("ContextMenu");
        }
        
                         [user=439709]@override[/user]
        public boolean onCreateOptionsMenu (Menu menu) {
            menu.add(1, 1, 1, R.string.settings);
            return true;
        }
        
        public boolean onOptionsItemSelected(MenuItem menuitem)
        {
        	boolean flag = true;
            switch (menuitem.getItemId())
            {
            case 1:
            	startActivity(new Intent(this, Settings.class));
            	break;
            }
            return flag;
        	
        }[/COLOR]
    
    private void SetupActionBar()
        {
            Object obj = new ActionBarExt(this, getActionBar());
            ((ActionBarExt)obj).setFullScreenEnabled(true);
            ((ActionBarExt)obj).enableHTCLandscape(false);
            mActionText = new ActionBarText(this);
            mActionText.setPrimaryText(R.string.app_name);
            obj = ((ActionBarExt)obj).getCustomContainer();
            ((ActionBarContainer)obj).setRightDividerEnabled(true);
            ((ActionBarContainer)obj).addCenterView(mActionText);
        }
        
    
                      [user=439709]@override[/user]
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		this.setGId(1);
            super.onCreate(savedInstanceState);
            final CarouselHost mPanelHost = getCarouselHost();
            SetupActionBar();
            
            mPanelHost.addTab("Tab1", this, R.string.tab_1,
                    R.drawable.ic_tab1,
                    R.drawable.ic_tab1,
                    R.drawable.ic_tab1, 
                        (new Intent("com.yourpackage.name.Tab1")));
       mPanelHost.addTab("Tab2", this, R.string.tab_2,
                    R.drawable.ic_tab2,
                    R.drawable.ic_tab2,
                    R.drawable.ic_tab2, 
                        (new Intent("com.yourpackage.name.Tab2"))); 
    	}
    
    
    }

    HTC AlertDialog

    In order to have alertdialog you need to have OnClickListener and inside OnClickListener you paste alertDialog.

    Code:
    public void onItemClick(HtcAdapterView<?> parent, View view, int position, long id) {
    
    [COLOR="red"]HtcAlertDialog.Builder[/COLOR] alertDialog = new [COLOR="red"]HtcAlertDialog.Builder[/COLOR]([B]YourActivity.this[/B]);
    				 
    alertDialog.setTitle(R.string.title_txt);
    
    alertDialog.setMessage(R.string.message_txt);
    alertDialog.setIcon(R.drawable.icon);
    
    alertDialog.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog,int which) {
    //Do your actions here when user click Yes
        }
          });
        alertDialog.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
    //Do your action here when user click No.. or just cancel dialog using follow..
    			     
        dialog.cancel();
    }
     });
          alertDialog.show();
       }

    As you can see Dialog is not so difficult, but need to identify exaclty which Builder you are gonna use.
    YourActivity.this - means the activity where you create the dialog


    You can also see available options of what you can implement inside dialog.. like 3 buttons.

    Start typing alertDialog. finish with the dot and in Eclipse there will be new pop-up window and you can add some more

    Also dont forget alertDialog.show(); at the end, otherwise Dialog wont shows​

    HTC ListView and HtcListActivity.

    There are two ways of implementing Htc List view. You can use Simple Activity, Fragment or just easy use HtcListActivity extension.
    For full htc style you need to use Main List layout, and Details layout + List adapter.


    Example using Activity


    Code:
    public class AboutActivity extends Activity {
    [COLOR="Red"]HtcListView lv1;[/COLOR]
        
    
       [user=439709]@override[/user]
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.about_activity);
    
    ArrayList<AboutDetails> image_details = GetSearchResults();
     
    [COLOR="red"]final HtcListView lv1 = (HtcListView) findViewById(R.id.about_list);[/COLOR]
       [user=1299008]@supp[/user]ressWarnings("unused")
    lv1.setAdapter(new AboutListBaseAdapter(this, image_details));
    lv1.setOnItemClickListener(new HtcAdapterView.OnItemClickListener() {
    Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
       [user=439709]@override[/user]
    public void onItemClick(HtcAdapterView<?> a, View v, int position, long id) {
        vibrator.vibrate(50); 
    Object o = lv1.getItemAtPosition(position);
    final AboutDetails obj_itemDetails = (AboutDetails)o;
    	} 
    });
    }
     
    private ArrayList<AboutDetails> GetSearchResults(){
    ArrayList<AboutDetails> results = new ArrayList<AboutDetails>();
     
    AboutDetails item_details = new AboutDetails();
    item_details.setName(R.string.mikrosmile);
    item_details.setItemDescription(R.string.mikrosmile_info);
    item_details.setImageNumber(1);
    results.add(item_details);
     
    return results;
    	}
    }

    AboutDetails

    Code:
    public class AboutDetails {
    	 
    public int getName() {
    return name;
    }
    public void setName(int name) {
    this.name = name;
    }
    public int getItemDescription() {
    return itemDescription;
    }
    public void setItemDescription(int itemDescription) {
    this.itemDescription = itemDescription;
    }
    
    public int getImageNumber() {
    return imageNumber;
    }
    public void setImageNumber(int imageNumber) {
    this.imageNumber = imageNumber;
    }
     
    private int name ;
    private int itemDescription;
    private int imageNumber;
     
    }
    
    AboutListBaseAdapter
    
    public class AboutListBaseAdapter extends BaseAdapter {
     private static ArrayList<AboutDetails> aboutDetailsrrayList;
      
     private Integer[] imgid = {
       R.drawable.mikrosmile,
       };
      
     private LayoutInflater l_Inflater;
     
     public AboutListBaseAdapter(Context context, ArrayList<AboutDetails> results) {
    	 aboutDetailsrrayList = results;
      l_Inflater = LayoutInflater.from(context);
     }
     
     public int getCount() {
      return aboutDetailsrrayList.size();
     }
     
     public Object getItem(int position) {
      return aboutDetailsrrayList.get(position);
     }
     
     public long getItemId(int position) {
      return position;
     }
     
     public View getView(int position, View convertView, ViewGroup parent) {
      ViewHolder holder;
      if (convertView == null) {
       convertView = l_Inflater.inflate(R.layout.about_htc_details, null);
       holder = new ViewHolder();
       holder.txt_itemName = ([COLOR="red"]HtcListItem2LineText[/COLOR]) convertView.findViewById(R.id.list_item);
       holder.itemImage = ([COLOR="red"]HtcListItemTileImage[/COLOR]) convertView.findViewById(R.id.list_item_img);
     
       convertView.setTag(holder);
      } else {
       holder = (ViewHolder) convertView.getTag();
      }
       
      holder.txt_itemName.setPrimaryText(aboutDetailsrrayList.get(position).getName());
      holder.txt_itemName.setSecondaryTextSingleLine(false);
      holder.txt_itemName.setSecondaryText(aboutDetailsrrayList.get(position).getItemDescription());
      holder.itemImage.setTileImageResource(imgid[aboutDetailsrrayList.get(position).getImageNumber() - 1]);
     
      return convertView;
     }
     
     static class ViewHolder {
      [COLOR="red"]HtcListItem2LineText txt_itemName;
      HtcListItemTileImage itemImage;[/COLOR]
     }
    }

    Layout - about_activity

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    	android:orientation="vertical" 
    	android:layout_width="fill_parent"
     	android:layout_height="fill_parent"
     	 	android:background="@drawable/bg_white">
    
    	
    	 <[COLOR="red"]com.htc.widget.HtcListView[/COLOR]
    	 	android:layout_height="fill_parent"
    	 	android:layout_width="fill_parent" 
    	 	android:id="@+id/about_list"
    	 	android:background="@drawable/common_app_bkg"
    />
    </LinearLayout>

    Layout - about_htc_details

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout 
        android:orientation="vertical" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
      xmlns:android="http://schemas.android.com/apk/res/android">
      <[COLOR="red"]com.htc.widget.HtcListItemSeparator [/COLOR]
            android:id="@+id/Lseparator" 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" />
        [COLOR="red"]<com.htc.widget.HtcListItem 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content">
            <com.htc.widget.HtcListItemTileImage 
                android:id="@+id/list_item_img" />
            <com.htc.widget.HtcListItem2LineText 
                android:id="@+id/list_item" />
        </com.htc.widget.HtcListItem>[/COLOR]
    </LinearLayout>



    HTC ListView Example by xcesco89
    4
    Edit: Didn't see mikrosmile's post ;)

    Ok, me and mikrosmile managed to get it working. Assuming you have OpenSense SDK at API level 16, Download the attached file (HTCExtension.jar) and put it into the htc addons folder in android sdk - for me its C:\Program Files (x86)\Android\android-sdk\add-ons\addon-htc_opensense_apis-htc-16\libs

    Then edit the manifest file found in C:\Program Files (x86)\Android\android-sdk\add-ons\addon-htc_opensense_apis-htc-16\ to this:

    Code:
    # SDK Add-on Manifest
    
    name=HTC OpenSense APIs
    name-id=HTC OpenSense SDK
    vendor=HTC
    vendor-id=htc
    description=HTC OpenSense APIs - Android SDK Add-on
    
    # version of the Android platform on which this add-on is built.
    api=16
    
    # revision of the add-on
    revision=1
    
    # list of libraries, separated by a semi-colon.
    libraries=htc-apis;HTCExtension
    
    # details for each library
    htc-apis=HTCSDK.jar; HTC OpenSense APIs Library
    HTCExtension=HTCExtension.jar; HTC OpenSense API's Extension

    Reload eclipse or whatever IDE you're using and it should appear in the HTC OpenSense API's dropdown :)

    For OpenSense SDK API level 15 put HTCExtension.jar attachment into C:\Program Files (x86)\Android\android-sdk\add-ons\addon-htc_opensense_sdk-htc-15\libs folder and change the manifest file found in C:\Program Files (x86)\Android\android-sdk\add-ons\addon-htc_opensense_sdk-htc-15 to:

    Code:
    # SDK Add-on Manifest
    
    name=HTC OpenSense SDK
    name-id=HTC OpenSense SDK
    vendor=HTC
    vendor-id=htc
    description=HTC OpenSense APIs - Android SDK Add-on
    
    # version of the Android platform on which this add-on is built.
    api=15
    
    # revision of the add-on
    revision=3
    
    # list of libraries, separated by a semi-colon.
    libraries=htc-apis;HTCExtension
    
    # details for each library
    htc-apis=HTCSDK.jar; HTC OpenSense APIs Library
    HTCExtension=HTCExtension.jar; HTC OpenSense API's Extension

    Then as above, reload the IDE