This page was last modified 15:54, 31 March 2008.
How to detect internet disconnection from application using red key
From Forum Nokia Wiki
Contents |
Purpose
Whenever an application has an active internet connection and if the user terminates the connection by long pressing the red/end call key, there is no way to capture the choice made by user in the "end data package query" and do the required cleanup. A workaround to this problem is the use of RConnectionMonitor & MConnectionMonitorObserver classes.
Headers to be included:
rconnmon.h
Link against theis libraries: ConnMon.lib
The following steps must be implemented
1. Derive your class from MConnectionMonitorObserver and give implementation for virtual function EventL(const CConnMonEventBase &aConnMonEvent)
2.Have a RConnectionMonitor class object in your class and whenever you initiate an internet connection connect your class to Connection Monitor Server using the function:ConnectL()
3.After connecting ,register your class to catch connection monitor events using the function: NotifyEventL(MConnectionMonitorObserver &aObserver)
4.Whenever there is a change in the status of the connection ,the TConnMonEvent events generated by the connection monitor are handled by the implemented EventL() function of the class.
Example Code
Header File
class CExampleClass : public CCoeControl, public MConnectionMonitorObserver { public: /* Some Functions */ //From MConnectionMonitorObserver void EventL (const CConnMonEventBase &aConnMonEvent); private: // Data RConnectionMonitor iConnectionMonitor; };
Source File
void CExampleClass::ConstructL( const TRect& aRect ) { /* Some Code */ User::LeaveIfError( iConnectionMonitor.ConnectL() ); //Connecting with server User::LeaveIfError( iConnectionMonitor.NotifyEventL( *this )); //Registering //with Server. // Set the main window size SetRect( aRect ); // Activate the window, which makes it ready to be drawn ActivateL(); } void CExampleClass::EventL (const CConnMonEventBase &aConnMonEvent) { switch ( aConnMonEvent.EventType() ) { case EConnMonDeleteConnection: { // Some Implementation break; } case EConnMonNetworkStatusChange: { // Some Implementation break; } case EConnMonConnectionStatusChange: { // Some Implementation break; } case EConnMonBearerChange: { // Some Implementation break; } default: break; } }
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Series 80 installation - Serial Key Problem | arvind_tiwari | Mobile Java Tools & SDKs | 0 | 2005-01-15 11:13 |
| Capturing keypresses in every view | emccnickw | Symbian User Interface | 2 | 2007-02-26 17:52 |
| how to detect if application is already minimimze | Liyo | Mobile Java General | 2 | 2007-11-26 07:54 |
| key repeat on s40 and s60 | johnmobile | Mobile Java General | 2 | 2004-02-05 19:37 |
| To handle volume keys in my application | ppreethijain | Mobile Java General | 3 | 2007-02-28 02:36 |
