Results 1 to 2 of 2
  1. #1
    Join Date
    May 2012
    Rep Power

    Default please help me invoke this call by reflection

    Hi All,

    I need to perform this call

    ActivityManagerNative.getDefault().resumeAppSwitch es();

    using reflection because this is a non public API.

    ActivityManagerNative is of type ActivityManagerNative (type is hidden to me)
    getDefault() is a static method that returns a IActivityManager object instance (the type IActivityManager is also hidden to me)
    resumeAppSwitches() is a method of IActivityManager.

    I tried this code :

    Class <?> AMN = Class.forName("android.os.ActivityManagerNative");
    Method getDefault = AMN.getMethod("getDefault", new Class[] {void.class});
    Object iam = getDefault.invoke(null, new Object[]{});
    Method resumeAppSwitches = iam.getClass().getMethod("resumeAppSwitches", new Class[] {void.class});
    resumeAppSwitches.invoke(iam, new Object[]{});

    Is this equivalent to the 'direct' call ?


  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: please help me invoke this call by reflection

    Quote Originally Posted by dextermagnific View Post
    Class <?> AMN = Class.forName("android.os.ActivityManagerNative");
    Moved from New to Java.

    Forum Rules
    BB Code List - Java Programming Forum

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. how to invoke sqlplus from jsp
    By shruthi.kashiprasad in forum New To Java
    Replies: 1
    Last Post: 04-12-2012, 11:05 AM
  2. reflection invoke method
    By pprl in forum New To Java
    Replies: 12
    Last Post: 11-16-2010, 06:43 PM
  3. How to call/invoke a Oracle package using java
    By sasi.tati in forum New To Java
    Replies: 4
    Last Post: 11-03-2010, 03:26 PM
  4. call by value and call by reference in java
    By sandeepsai39 in forum New To Java
    Replies: 7
    Last Post: 08-12-2010, 12:03 PM
  5. Array Reflection: Multi Array Reflection
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-23-2008, 09:08 PM

Posting Permissions

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