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

    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 ?

    Thanks

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

    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
    Guide For New Members
    BB Code List - Java Programming Forum

    db
    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, 10:05 AM
  2. reflection invoke method
    By pprl in forum New To Java
    Replies: 12
    Last Post: 11-16-2010, 05: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, 02: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, 11:03 AM
  5. Array Reflection: Multi Array Reflection
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-23-2008, 08: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
  •