×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    29

    Detecting Memory Card Insertion

    Hi,

    I want to detect memory card insertion. How can I catch that event. Please reply.

    Thanks in advance..

  2. #2
    Regular Contributor
    Join Date
    Dec 2007
    Location
    India
    Posts
    155

    Re: Detecting Memory Card Insertion

    Hi try this code for detecting a device has a memory card or not


    RFs fileSession;
    fileSession.Connect();

    TDriveInfo i;
    if (fileSession.Drive(i, EDriveE)==KErrNone) {
    if (i.iType!=EMediaNotPresent &&
    i.iType!=EMediaUnknown &&
    i.iType!=EMediaCdRom &&
    i.iType!=EMediaRom) {
    // memory card
    iHasMMC=ETrue;
    }
    }
    Regards
    Md.kashif

  3. #3
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: Detecting Memory Card Insertion

    Please search the knowledge base or wiki first before posting.

    http://wiki.forum.nokia.com/index.ph...removal_events
    Download Symbian OS now! [url]http://developer.symbian.org[/url]

  4. #4
    Regular Contributor
    Join Date
    Jul 2008
    Posts
    179

    Re: Detecting Memory Card Insertion

    Hi,

    I'm trying the same thing, but the solution provided in WIKI is not working.
    Whenever I'm calling the Notify method
    iFs.NotifyDiskSpace(KThreshold, EDriveE, iStatus);

    the iStaus value is not equal to KErrNone, means request is not completing.

    Is there any other way to monitor the memory card insertion/removal?

  5. #5
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: Detecting Memory Card Insertion

    the iStaus value is not equal to KErrNone, means request is not completin
    Is it equal to KRequestPending or an error code. If so what is the error code.
    My guess is this is a mis understanding on how Active Objects work.
    Download Symbian OS now! [url]http://developer.symbian.org[/url]

  6. #6
    Regular Contributor
    Join Date
    Jul 2008
    Posts
    179

    Re: Detecting Memory Card Insertion

    Thanks Paul,

    It's a KRequestPending only. But why I'm getting request pending always. Even though I made active object priority from Standard to High. I need to make this request complete, then only RunL will get called.

    Am I making any mistake?

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,684

    Re: Detecting Memory Card Insertion

    Do you actually insert/remove the card (or at least simulate such event in the emulator)?
    How does your code look like?

  8. #8
    Regular Contributor
    Join Date
    Jul 2008
    Posts
    179

    Re: Detecting Memory Card Insertion

    Hi,

    Following is my code

    Source
    Code:
    #include "MMCMonitor.h"
    #include "Logger.h"
    
    
    const TInt64 KThreshold = 0x1000; // Threshold value for free disk space
    
    
    CMMCMonitor::CMMCMonitor() :
    	CActive(EPriorityHigh) // Standard priority : EPriorityStandard
    	{
    	}
    
    CMMCMonitor* CMMCMonitor::NewLC()
    	{
    	CMMCMonitor* self = new ( ELeave ) CMMCMonitor();
    	CleanupStack::PushL(self);
    	self->ConstructL();
    	return self;
    	}
    
    CMMCMonitor* CMMCMonitor::NewL()
    	{
    	CMMCMonitor* self = CMMCMonitor::NewLC();
    	CleanupStack::Pop(); // self;
    	return self;
    	}
    
    void CMMCMonitor::ConstructL()
    	{
    	User::LeaveIfError(iFs.Connect());
    	CActiveScheduler::Add( this); // Add to scheduler
    	}
    
    CMMCMonitor::~CMMCMonitor()
    	{
    	Cancel(); // Cancel any request, if outstanding
    	iFs.Close();
    	}
    
    void CMMCMonitor::DoCancel()
    	{
    	iFs.NotifyDiskSpaceCancel();
    	}
    
    void CMMCMonitor::StartL()
    	{
    	Cancel(); // Cancel any request, just to be sure
    	iFs.NotifyDiskSpace(KThreshold, EDriveE, iStatus);
    	if(iStatus == KErrNone)
    		{
    		LOG(_L("Request Completed"))
    		CEikonEnv::Static()->AlertWin(_L("Request Completed"));
    		}
    	else if (iStatus == KRequestPending)
    		{
    		LOG(_L("Request Pending"))
    		CEikonEnv::Static()->AlertWin(_L("Request Pending"));
    		}
    	else
    		{
    		LOG1(_L("Request NOT Completed- %d"), iStatus.Int())
    		CEikonEnv::Static()->AlertWin(_L("Request Not Completed"));
    		}
    	SetActive(); // Tell scheduler a request is active
    	}
    
    void CMMCMonitor::RunL()
    	{
    	LOG(_L("Inside RUNL"))
    	
    	if(iStatus == KErrNone)
    		{
    		// Threshold value has been crossed - memory card has been
    		// inserted or removed
    		LOG(_L("memory card has been inserted or removed"))
    		CEikonEnv::Static()->AlertWin(_L("MMC removed/inserted"));
    		iFs.NotifyDiskSpace(KThreshold, EDriveE, iStatus);
    		SetActive(); // Tell scheduler a request is active
    		}
    	}
    
    TInt CMMCMonitor::RunError(TInt aError)
    	{
    	return aError;
    	}
    And I'm calling it from AppUi::HandleCommandL as follows:

    CMMCMonitor *mmcMonitor = CMMCMonitor::NewL();
    mmcMonitor->StartL();



    Is there any mistake?

  9. #9
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: Detecting Memory Card Insertion

    The active object will complete when the card is inserted or removed, it will not happen immediately.

    As Wizard suggested, simulate adding or removing the mmc card using the options in the emulators Tools|Utilities dialog.

    Also remember that your application will be closed by default unless you mark the application as busy as all apps are closed when the mmc card is removed.
    Download Symbian OS now! [url]http://developer.symbian.org[/url]

  10. #10
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,684

    Re: Detecting Memory Card Insertion

    And what do you see in your log? I would guess the pending message, but could you confirm that.
    Otherwise Paul is most probably right about that your application gets terminated prior to the card is removed.

  11. #11
    Regular Contributor
    Join Date
    Jul 2008
    Posts
    179

    Re: Detecting Memory Card Insertion

    Yes, I'm getting "Request Pending" in log.
    And my application is not terminating as I made it system app by adding code line
    CEikonEnv::Static()->SetSystem( ETrue );

    I checked on device too, still it is showing request pending. I also tried with removing memory card on actual device.

  12. #12
    Registered User
    Join Date
    Jan 2009
    Location
    India
    Posts
    143

    Arrow Re: Detecting Memory Card Insertion

    Hi,
    Unable to getthe MMC insertion Event.

    i have designed my code with the help of following link http://wiki.forum.nokia.com/index.ph...removal_events

    My Code
    code snippet:


    const TInt64 KThreshold = 0x1000; // Threshold value for free disk space

    CAO_Test::ConstructL()
    {
    iFs.NotifyDiskSpace(KThreshold, EDriveE, iStatus);
    }

    void CAO_Test::RunL()
    {
    if (iStatus == KErrNone)
    {
    // Threshold value has been crossed - memory card has been
    // inserted or removed


    CLog::WriteLog(_L8("disk has been removed"),_L8("or inserted"));
    }


    iFs.NotifyDiskSpace(KThreshold, EDriveE, iStatus);

    SetActive();
    }


    am able to catch MMC removal event,and i need to get memory card insertion Event

    any1 pls help me


    Thaanks in Advance


    Gobi.S

  13. #13
    Registered User
    Join Date
    Aug 2007
    Location
    Bangalore (INDIA)
    Posts
    38

    Re: Detecting Memory Card Insertion

    Quote Originally Posted by gobi_est View Post

    am able to catch MMC removal event,and i need to get memory card insertion Event

    any1 pls help me

    Gobi.S
    Hi Gobi.s,

    Did you get any solution for Memory card insertion Event?

    Thanks in Advance!!!
    Thanks & Regards,
    Md.Khalid Ahmad

  14. #14
    Registered User
    Join Date
    May 2008
    Posts
    20

    Re: Detecting Memory Card Insertion

    Is there anyone make it work?
    Last edited by hyuan; 2009-03-18 at 19:57.

  15. #15
    Nokia Developer Champion
    Join Date
    Jul 2004
    Posts
    2,015

    Re: Detecting Memory Card Insertion

    Quote Originally Posted by Paul.Todd View Post
    Please search the knowledge base or wiki first before posting.

    http://wiki.forum.nokia.com/index.ph...removal_events

    Who writes this stuff for Nokia? What has a windows group got to do with using RFs?

Similar Threads

  1. Help to format memory card (Nokia 5300)
    By public2 in forum General Development Questions
    Replies: 0
    Last Post: 2007-07-21, 17:21
  2. Can't run native Symbian apps on memory card after phone restart
    By stewart.hector in forum General Development Questions
    Replies: 5
    Last Post: 2007-05-28, 11:19
  3. Nokia N80 Memory Card gets full - without beeing so?!
    By thunder7553 in forum General Development Questions
    Replies: 0
    Last Post: 2006-07-06, 09:25
  4. Storing my data on memory card on Series 40 phones
    By Sammybar in forum Mobile Java General
    Replies: 1
    Last Post: 2005-12-28, 17:40
  5. can not successfully link any sample using .NET
    By lobotomat in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2002-08-20, 00:29

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×