Calling an Activity when phone is locked by clicking two times on the END_CALL button

23 views
Skip to first unread message

souissi haythem

unread,
May 13, 2011, 7:56:25 AM5/13/11
to android-ndk
Hi,

I need to call my Activity when user press two times on the END_CALL
button (it need to work when the phone is locked).

Is is that possible??

Thanks.

David Turner

unread,
May 13, 2011, 12:08:15 PM5/13/11
to andro...@googlegroups.com
Nope, you can't do that. Too many security issues with allowing something like that.
 
Thanks.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


Chris Stratton

unread,
May 13, 2011, 1:41:51 PM5/13/11
to andro...@googlegroups.com
On Friday, May 13, 2011 12:08:15 PM UTC-4, Digit wrote:
On Fri, May 13, 2011 at 1:56 PM, souissi haythem <hayt...@gmail.com> wrote:
Hi,

I need to call my Activity when user press two times on the END_CALL
button (it need to work when the phone is locked).

Is is that possible??

Nope, you can't do that. Too many security issues with allowing something like tha

This is in the domain of a system modification rather than an sdk/ndk application for consumer phones.

It the idea has merit, implement it on top of an unofficial android build, gain some early-adopter user experience that way... theoretically you could then submit a patch to the official tree, but how knows where that will go.

souissi haythem

unread,
May 14, 2011, 10:19:41 AM5/14/11
to android-ndk
hi,
thanks for replying. I'm new to this stuff and couldn't fully
andrestand what you meant by "unofficial android", could explain more
please. I just don't know where to begin.
many thanks.

Chris Stratton

unread,
May 14, 2011, 12:44:51 PM5/14/11
to andro...@googlegroups.com
There are a number of people/groups that have taken the official AOSP releases and evolved them into a complete firmware people are actually using on phones (with varying degrees of stability) vs. the more proof-of-concept/starting-point nature of AOSP.  Probably the most famous is "cyanogenmod".
You can download their sources, and in a few hours (depending on your machine) have a locally built version of android which you can start trying to modify.  

On Saturday, May 14, 2011 10:19:41 AM UTC-4, souissi haythem wrote:
hi,
thanks for replying. I'm new to this stuff and couldn't fully
andrestand what you meant by "unofficial android", could explain more
please. I just don't know where to begin.
many thanks.

On 13 mai, 19:41, Chris Stratton <cs0...@gmail.com> wrote:
> On Friday, May 13, 2011 12:08:15 PM UTC-4, Digit wrote:

souissi haythem

unread,
May 16, 2011, 3:31:16 AM5/16/11
to android-ndk
Hi

it will be so complicated!!!
So before i try to change "cyanogenmod", i wanna know if it will be
possible to lunch my application by two click on the CALL button or
the BACK button?

Maybe i can use broadcast or a listner on a button?? Please i wanna
know if listner can be lunch when my activity is in stop or
destroyed??

thanks

souissi haythem

unread,
May 16, 2011, 3:53:28 AM5/16/11
to android-ndk
Hi

it will be so complicated!!!
So before i try to change "cyanogenmod", i wanna know if it will be
possible to lunch my application by two click on the CALL button or
the BACK button?

Maybe i can use broadcast or a listner on a button?? Please i wanna
know if listner can be lunch when my activity is in stop or
destroyed??

thanks




On 14 mai, 18:44, Chris Stratton <cs07...@gmail.com> wrote:

souissi haythem

unread,
May 16, 2011, 11:07:15 AM5/16/11
to android-ndk

in the first time
I found this in the site of android:

When examining whether or not you should develop in native code, think
about your requirements and see if the Android framework APIs provide
the functionality that you need. The NDK can, however, can be an
effective way to reuse a large corpus of existing C/C++ code.

in my case there is no API providing solution i need.


in the second time
i have the code in c++ of my application.it was developped to a Nokia
phone.

I have used:
• L’IDE Carbide C++
• Le SDK Symbian adapté au téléphone utilisé
• Une distribution de Perl nécessaire pour le SDK

can i make it functionnal in an Android phone?

thanks

Chris Stratton

unread,
May 16, 2011, 11:28:25 AM5/16/11
to andro...@googlegroups.com
On Monday, May 16, 2011 3:53:28 AM UTC-4, souissi haythem wrote:
it will be so complicated!!!

Because you are trying to do something that the people who designed android intentionally didn't make available.
 
So before i try to change "cyanogenmod", i wanna know if it will be
possible to lunch my application by two click on the CALL button or
the BACK button?

Maybe i can use broadcast or a listner on a button?? Please i wanna
know if listner can be lunch when my activity is in stop or
destroyed??
 
You cannot do this with an SDK application on an official production build of android; you will have to use a customized build and customize it further. 

You are certainly welcome to try to get the official AOSP sources to build into something useful for your device; I think it's probably simpler to start with a power-user/modder oriented unofficial distribution.

souissi haythem

unread,
May 16, 2011, 12:12:37 PM5/16/11
to android-ndk
Yes , it 's a good solution, but i have to do this application and i
prefer not to touch or change the android OS. Because it will not be a
general application, it will be necessary to have the "cyanogenmod" i
change.

is that your idea? did i understand your idea?


thanks for repling

Dianne Hackborn

unread,
May 16, 2011, 12:51:10 PM5/16/11
to andro...@googlegroups.com
On Mon, May 16, 2011 at 9:12 AM, souissi haythem <hayt...@gmail.com> wrote:
Yes , it 's a good solution, but i have to do this application and i
prefer not to touch or change the android OS.

You can't do this without changing Android.  This functionality is not available to applications.  Period.
 
Because it will not be a
general application, it will be necessary to have the "cyanogenmod" i
change.

cyanogenmod is just another distribution of Android with their own changes to it. I don't think they have the change you are asking for here, so you still need to modify the platform code in cyanogenmod to do what you want and flash it on to your device.

--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Chris Stratton

unread,
May 16, 2011, 1:32:40 PM5/16/11
to andro...@googlegroups.com
On Monday, May 16, 2011 12:51:10 PM UTC-4, Dianne Hackborn wrote:

cyanogenmod is just another distribution of Android with their own changes to it. I don't think they have the change you are asking for here, so you still need to modify the platform code in cyanogenmod to do what you want and flash it on to your device.--

The proposal will require modifications to an android distribution, but the first challenge is going to be just compiling a distribution from source, installing it, and making sure everything works. 

I think the OP is more likely to find some kinship of motive with the maintainers of unofficial builds than with the maintainers of the official AOSP, so that might be a reason to start with an unofficial build that's more associated with technical-end-user modifications vs intended to be an engineering reference design.

souissi haythem

unread,
May 17, 2011, 12:35:02 PM5/17/11
to android-ndk
Thanks every one,

I got another idea:
can i use broadcast on ACTION_SCREEN_OFF and ACTION_SCREEN_ON ?
so when there is an ACTION_SCREEN_OFF and an ACTION_SCREEN_ON
simultanous, i lunch my service or my activity?
by this method i manipulate the END_CALL button indirectly

is that possible?

souissi haythem

unread,
May 17, 2011, 12:38:11 PM5/17/11
to android-ndk
so when there is an ACTION_SCREEN_OFF and an ACTION_SCREEN_ON
successive service start.

Tim Mensch

unread,
May 17, 2011, 12:45:47 PM5/17/11
to andro...@googlegroups.com
On 5/17/2011 10:35 AM, souissi haythem wrote:
> can i use broadcast on ACTION_SCREEN_OFF and ACTION_SCREEN_ON ?
> so when there is an ACTION_SCREEN_OFF and an ACTION_SCREEN_ON
> simultanous, i lunch my service or my activity?
> by this method i manipulate the END_CALL button indirectly

This is leaving "NDK" territory, so you might have better luck asking
that question on another list. But I wanted to mention, in case you
weren't aware, that some phones don't even have the "END_CALL" button of
which you speak -- your previous messages make it seem like you want to
make a product that will work on end users' phones, but a lot of popular
phones (Droid/Milestone, for instance, and its siblings) don't even have
the button you're trying to detect for.

Tim

souissi haythem

unread,
May 17, 2011, 12:51:02 PM5/17/11
to android-ndk
Yes it is true. but it will not be a problem, i will choose the BACK
button in that case.
Will that be possible with the back button or any other physical
button?

On 17 mai, 18:45, Tim Mensch <tim.men...@gmail.com> wrote:
> On 5/17/2011 10:35 AM,souissihaythemwrote:

Tim Mensch

unread,
May 17, 2011, 1:07:50 PM5/17/11
to andro...@googlegroups.com
This still isn't really an appropriate question for the NDK list (i.e.,
THIS list), but the BACK (and MENU) buttons each send a key to the
active app, and (for security reasons at the very least!) you can't peek
at another application's key queue.

It is possible to become the "home key" app (I've seen the game Toddler
Lock do this, so that the toddler playing with it can't get out of the
game by hitting the home button), with the user's permission, but I
don't know that you can get the functionality you want from that. It's
probably your best bet, however.

Tim

souissi haythem

unread,
May 18, 2011, 3:20:44 AM5/18/11
to android-ndk
Hi,

> This still isn't really an appropriate question for the NDK list (i.e.,
> THIS list),

I posted in ndk because i thought that maybe it will possible to
translate my code in c++ to android. Than i have experience in c++ and
no much in android.
I had done the same application for symbian en se basant sur le modèle
client-serveur. L'application cliente dialogue avec le window Server
(WS), qui gère les évènements d'interface (dont le clavier) et
l'affiche à l'écran.


> It is possible to become the "home key" app (I've seen the game Toddler
> Lock do this, so that the toddler playing with it can't get out of the
> game by hitting the home button), with the user's permission, but I
> don't know that you can get the functionality you want from that. It's
> probably your best bet, however.

public static final int KEYCODE_HOME : Key code constant: Home key.
This key is handled by the framework and is never delivered to
applications.
http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_HOME


Thanks

Tim Mensch

unread,
May 24, 2011, 1:37:35 PM5/24/11
to andro...@googlegroups.com
On 5/18/2011 1:20 AM, souissi haythem wrote:
>> This still isn't really an appropriate question for the NDK list (i.e.,
>> THIS list),
> I posted in ndk because i thought that maybe it will possible to
> translate my code in c++ to android. Than i have experience in c++ and
> no much in android.

This list is for discussing the NDK part, though, not for discussing any
aspect of any application that might use the NDK for some of its
functionality. If you're asking how to call an Android API from the NDK,
that's an NDK question. You're asking about how to do something on
Android at all, which is the topic of other lists and sites.

>> It is possible to become the "home key" app (I've seen the game Toddler
>> Lock do this, so that the toddler playing with it can't get out of the
>> game by hitting the home button), with the user's permission, but I
>> don't know that you can get the functionality you want from that. It's
>> probably your best bet, however.
> public static final int KEYCODE_HOME : Key code constant: Home key.
> This key is handled by the framework and is never delivered to
> applications.
> http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_HOME

Sigh. This STILL not being the right list, you might try asking how to
become the "home" app in the main Android developer list instead, as I
suggested. I never implied you could see the home key at the app level;
re-read what I wrote above about "with the user's permission". How often
do you need the user's permission to compare a key value to a constant?
I also pointed you at an app that does what I'm talking about, if you
don't believe me; a permission dialog comes up when you use it, asking
whether to allow the app to register as the "home" app.

Tim

Reply all
Reply to author
Forward
0 new messages