Lock/Home Button Event

madSac

Active Member
Licensed User
Longtime User
Hello,
I want to just wake an event when user presses Home key & Lock Key/Switch Off Key. & i also want to cancel the event if possible.
Anyone has any solution..Help me..please
 
thank you Erel , but I already saw those post,
I want to register app as home application til my first app is running, I can provide option to choose.my app. As home app at first run of application, but how to un register.it on application close & how to invoke an event from my home screen application to my primary application....?
 
Upvote 0
Upon exiting, you can use something like this
Code:
Dim i As Intent
            i.Initialize (i.ACTION_MAIN ,"")
            i.AddCategory ("android.intent.category.HOME")
            i.Flags =0x3400000
            i.SetComponent ("android/com.android.internal.app.ResolverActivity")
            StartActivity(i)

But this will get user to a popUp selection screen, so not sure if this can be useful in your case.
 
Upvote 0
Upon exiting, you can use something like this
Code:
Dim i As Intent
            i.Initialize (i.ACTION_MAIN ,"")
            i.AddCategory ("android.intent.category.HOME")
            i.Flags =0x3400000
            i.SetComponent ("android/com.android.internal.app.ResolverActivity")
            StartActivity(i)

But this will get user to a popUp selection screen, so not sure if this can be useful in your case.

i used above code like this
Code:
Sub Activity_Create(FirstTime As Boolean)
Dim i As Intent
            i.Initialize (i.ACTION_MAIN ,"")
            i.AddCategory ("android.intent.category.HOME")
            i.Flags =0x3400000
            i.SetComponent ("android/com.android.internal.app.ResolverActivity")
            StartActivity(i)
......
but it did not had any effect on application...no popup to choose my app at home key press or lock key press.
Please guide me if i am wrong somewhere.
Thank You
 
Upvote 0
NO, nothing wrong. I forgot to tell you to add the following to your manifest file (from b4a choose manifest editor):
AddActivityText("main",
<
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.MONKEY"/>
</
intent-filter>)
[/code]
Now, you can try this, but please notice that initially user has to choose your app as a home screen app.
 
Upvote 0
NO, nothing wrong. I forgot to tell you to add the following to your manifest file (from b4a choose manifest editor):
AddActivityText("main",
<
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.MONKEY"/>
</
intent-filter>)
[/code]
Now, you can try this, but please notice that initially user has to choose your app as a home screen app.
I worked but how to remove it.
 
Upvote 0
What do you mean? Upon exiting the app, use the previous code in order that the user decides whether to have the normal android's launcher or yours. Usually, I do this by setting an 'admin' password, upon exiting the app.
 
Upvote 0
What do you mean? Upon exiting the app, use the previous code in order that the user decides whether to have the normal android's launcher or yours. Usually, I do this by setting an 'admin' password, upon exiting the app.
No, i want to register application on home key till app is running and unregister when it is closed.
 
Upvote 0
Back
Top