1

当我启动 android 时,我希望屏幕自动解锁(并运行应用程序)而不是我解锁屏幕。谁能告诉我必须在哪里更改内核源代码?


java代码在这里..你能纠正一下吗

public class AddnumsActivity extends BroadcastReceiver {
    private static final String KEYGUARD_SERVICE = null;
        @Override
        public void onReceive(Context context, Intent intent) {
            // TODO Auto-generated method stub
            KeyguardManager keyguardManager = (KeyguardManager)context.getSystemService(Activity.KEYGUARD_SERVICE);
            KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
            lock.disableKeyguard();
            if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {  
                Intent pushIntent = new Intent(context, AddnumsActivity.class);  
                pushIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(pushIntent);  
            }
        }
    }
4

1 回答 1

0

我认为您不需要为此进行内核更改。您所要做的就是创建一个完整的启动接收器并在其中禁用锁定屏幕

KeyguardManager keyguardManager = KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE);
KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
lock.disableKeyguard();

并添加以下权限

<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>

您需要在启动时显示的活动应充当主屏幕。为您的活动使用以下过滤器

<intent-filter>
 <action android:name="android.intent.action.MAIN" />
 <category android:name="android.intent.category.HOME" />
 <category android:name="android.intent.category.DEFAULT" />
</intent-filter>
于 2012-08-28T04:19:14.983 回答