I need to override Home button for Lock Screen App. And I found the following answer which restart the app after 6 seconds on home button press.
protected void onUserLeaveHint() {
Intent i=new Intent(this,MainActivity123.class);
startActivity(i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT));
Toast.makeText(this,"leaveHint",Toast.LENGTH_SHORT).show();
}
But I want to start the app immediately. So I guess thier was an answer saying if we make our app default Launcher app than thier will be no time gap.So i added in my manifest
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
But this is not working and app still restart after 6 sec. what should i do.
So Spend some more researching and found another method {used to go to a default screen in launcher When you are already on home screen} The method called automatically using appropriate flag in startActivity()
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Toast.makeText(this,"onNewEvent",Toast.LENGTH_SHORT).show();
if ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) !=
Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) {
Toast.makeText(this,"onNewEvent",Toast.LENGTH_SHORT).show();
//++goHome++
startActivity(intent);
}
}
The method is get called But app still starts after 6 sec. SO no progress Any suggestion........