android widget跳转至系统时间界面

PackageManager packageManager = getPackageManager();

Intent alarmClockIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER);


// Verify clock implementation

String clockImpls[][] = {

        {"HTC Alarm Clock","com.htc.android.worldclock","com.htc.android.worldclock.WorldClockTabControl" },

        {"Standar Alarm Clock","com.android.deskclock","com.android.deskclock.AlarmClock"},

        {"Standar Alarm Clock2","com.android.deskclock","com.android.deskclock.DeskClock"},

        {"Froyo Nexus Alarm Clock","com.google.android.deskclock","com.android.deskclock.DeskClock"},

        {"Moto Blur Alarm Clock","com.motorola.blur.alarmclock""com.motorola.blur.alarmclock.AlarmClock"},

        {"Samsung Galaxy Clock","com.sec.android.app.clockpackage","com.sec.android.app.clockpackage.ClockPackage"},

        {"Google Galaxy Nexus Clock","com.google.android.deskclock","com.android.deskclock.AlarmClock"}

};


boolean foundClockImpl =false;


for(int i=0; i<clockImpls.length; i++) {

    String vendor = clockImpls[i][0];

    String packageName = clockImpls[i][1];

    String className = clockImpls[i][2];

    try {

        ComponentName cn = new ComponentName(packageName, className);

        ActivityInfo aInfo = packageManager.getActivityInfo(cn, PackageManager.GET_META_DATA);

        alarmClockIntent.setComponent(cn);

        System.out.println("Found " + vendor +" --> " + packageName +"/" + className);

        foundClockImpl = true;

    } catch (NameNotFoundException e) {

    System.out.println(vendor +" does not exists");

    }

}


if (foundClockImpl) {

    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, alarmClockIntent, 0);

        // add pending intent to your component

    remoteViews.setOnClickPendingIntent(R.id.TimeLeftHotArea,

pendingIntent);

}

不同生产商调用的包名类名的查看:

android-sdk\tools\hierarchyviewer.bat,打开这个工具,手机连接电脑,启动对应界面,就能看到包名 类名



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值