解锁界面滑环增加多个方向功能

一般android的解锁界面 滑环只有2个方向  怎么增加多个方向多个功能呢.

在 frameworks\base\policy\src\com\android\internal\policy\impl\LockScreen.java

onTrigger里做如下修改:

 

        public void onTrigger(View v, int target) {
            if (target == 0) { // 0 = unlock/portrait, 1 = unlock/landscape
                mCallback.goToUnlockScreen();
            }
            else if(target == 1)
            {
          Intent intent = new Intent();
    intent.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity"));
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                mContext.startActivity(intent); 
                mCallback.goToUnlockScreen();
            }
            else if(target == 2)
            {
          Intent intent = new Intent();
    intent.setComponent(new ComponentName("com.android.email", "com.android.email.activity.Welcome"));
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                mContext.startActivity(intent); 
                mCallback.goToUnlockScreen();
            }
            else if(target == 3)
            {
          Intent intent = new Intent();
    intent.setComponent(new ComponentName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"));
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                mContext.startActivity(intent); 
                mCallback.goToUnlockScreen();
            }
            else if (target == 4) { // 2 = alt/portrait, 3 = alt/landscape
               if (!mCameraDisabled) {
                    // Start the Camera  (Gallery)
    // Intent intent = new Intent();
    // intent.setComponent(new ComponentName("com.android.gallery3d", "com.android.gallery3d.app.Gallery"));
                  //  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                 //   mContext.startActivity(intent);
                    Intent intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    mContext.startActivity(intent);
                    mCallback.goToUnlockScreen();
                }
            }
               else if(target == 5)
               {
             Intent intent = new Intent();
       intent.setComponent(new ComponentName("com.android.gallery3d", "com.android.gallery3d.app.Gallery"));
                   intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                   mContext.startActivity(intent); 
                   mCallback.goToUnlockScreen();
               }
               else if(target == 6)
               {
             Intent intent = new Intent();
       intent.setComponent(new ComponentName("com.android.music", "com.android.music.MusicBrowserActivity"));
                   intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                   mContext.startActivity(intent); 
                   mCallback.goToUnlockScreen();
               }
               else if(target == 7)
               {
             Intent intent = new Intent();
       intent.setComponent(new ComponentName("com.android.vending", "com.android.vending.AssetBrowserActivity"));
                   intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                   mContext.startActivity(intent); 
                   mCallback.goToUnlockScreen();
               }

        
               else {
                    toggleRingMode();
                    mUnlockWidgetMethods.updateResources();
                    mCallback.pokeWakelock();
                }
        }

八个方向对应八个功能

在 frameworks\base\core\res\res\values\arrays.xml里

    <array name="lockscreen_targets_with_camera">
        <item>@drawable/ic_lockscreen_unlock</item>
        <item>@drawable/ic_lockscreen_browser</item>
        <item>@drawable/ic_lockscreen_email</item>
        <item>@drawable/ic_lockscreen_maps</item>
        <item>@drawable/ic_lockscreen_camera</item>
        <item>@drawable/ic_lockscreen_gallery3d</item>
        <item>@drawable/ic_lockscreen_music</item>
        <item>@drawable/ic_lockscreen_playstore</item>
    </array>
各个方向的图标配置

 

frameworks\base\core\res\res\values-sw600dp-land\arrays.xml里

这样就可以实现功能

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值