1

When I boot the android, I want the screen to be unlocked automatically (and run an application) rather than me unlocking the screen . Can anyone tell me where the kernel source code change has to be done to do so ?


The java code is here.. Can you please correct it

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);  
            }
        }
    }
Community
  • 1
  • 1
johnsonpinto
  • 61
  • 2
  • 9

1 Answers1

0

I dont think you need to do kernel changes for this. All you got to do is Create a boot complete Reciever and disable lock screen in it

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

And add below permission

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

And your activity which needs to be shown at startup should act as home screen. Use below filter for your activity

<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>
nandeesh
  • 24,740
  • 6
  • 69
  • 79