确定设备是否正在使用HTC SenseUI

时间:2010-08-25 22:03:53

标签: android

如何判断设备是否正在使用HTC的SenseUI?

我考虑过使用android.os.Build信息,但它们似乎不一致..有更明确的方法吗?

我需要能够通过使用com.android.calendar或com.htc.calendar来判断我是否可以启动日历。

我欢迎任何建议!!

3 个答案:

答案 0 :(得分:0)

欢迎您使用PackageManager查看设备上是否存在com.htc.calendar。您可以使用PackageManager派生Intent来打开该包。是否“推出(HTC)日历”取决于HTC和Android,而不是你。

此外,正如Marya建议的那样,你所做的并不是一个好主意,因为没有规则HTC将在现在和未来的每个Sense设备上使用com.htc.calendar

答案 1 :(得分:0)

根据CommonsWare的建议,以下是我最终使用的内容。我希望这对其他人有帮助。

    PendingIntent pendingIntent = null;
    Intent defineIntent = null;

    String thePackage = "com.android.calendar";
    String theClassName = "com.android.calendar.LaunchActivity";

    try {
        PackageManager thePackageManager = context.getPackageManager();
        thePackageManager.getPackageInfo(thePackage,PackageManager.GET_ACTIVITIES);
    } catch (PackageManager.NameNotFoundException e){
        // regular android calendar doesn't exist

        // so try the htc sense one
        thePackage = "com.htc.calendar";
        theClassName = "com.htc.calendar.LaunchActivity";               
    }

    defineIntent = new Intent(Intent.ACTION_MAIN)
        .addCategory(Intent.CATEGORY_LAUNCHER)
        .setComponent(new ComponentName(thePackage, theClassName));

    pendingIntent = PendingIntent.getActivity(context,
        0 /* no requestCode */, defineIntent, 0 /* no flags */);
    views.setOnClickPendingIntent(R.id.widget, pendingIntent);

答案 2 :(得分:0)

String thePackage = "com.android.calendar";
String theClassName = "com.android.calendar.LaunchActivity";
Intent defineIntent = null;

try {
    PackageManager PACKAGE_NAME = getApplicationContext().getPackageManager();
    PACKAGE_NAME.getPackageInfo(thePackage,PackageManager.GET_ACTIVITIES);
} catch (PackageManager.NameNotFoundException e){
    // regular android calendar doesn't exist
    // so try the htc sense one
    thePackage = "com.sonyericsson.calendar";
    theClassName = "com.sonyericsson.calendar.MonthActivity";               
}

defineIntent = new Intent(Intent.ACTION_MAIN); 
defineIntent.setComponent(new ComponentName(thePackage, theClassName)); 
startActivity(defineIntent);