Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6855525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:46:11+00:00 2026-05-27T01:46:11+00:00

I am struggling with the idea of getting CustomView from another application. Lets say

  • 0

I am struggling with the idea of getting CustomView from another application. Lets say I have two applications A and B. I know package name of CustomView, for example com.applicationb.CustomView. Is it possible to create an Object of this Class in application A at runtime?

My aim is to find a way to create CustomViews and being able to show them in my application. But I want them (views) to be a separate apk, which may be published to Android Market, and downloaded as some kind of extension.

CustomView would only display somekind of animation on screen (for example falling leaves). It would not work on any data in first application.

Edit

I found something like this:

@SuppressWarnings("rawtypes")
Class c = Class.forName(package_name);
Method m = c.getDeclaredMethod(method_name);
m.setAccessible(true);
Canvas can= (Canvas) m.invoke(null, null); // since there are no parameters, and called function is static

I hope this will work. I let you know.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:46:12+00:00Added an answer on May 27, 2026 at 1:46 am

    As I promissed here is result.

    String packageName = "com.exapmle.sth";
    String className = "com.exapmle.sth.CustomView";
    
    String apkName = getPackageManager().getApplicationInfo(
        packageName, 0).sourceDir;
    PathClassLoader myClassLoader = new dalvik.system.PathClassLoader(
        apkName, ClassLoader.getSystemClassLoader());
    Class<?> handler = Class.forName(className, true, myClassLoader);
    Constructor[] m = handler.getConstructors();
    for (int i = 0; i < m.length; i++) {
        if (m[i].getName().contains("CustomView")) {
            animation = (View)m[i].newInstance(new Object[] { this });
            rootRL.addView(animation, new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.FILL_PARENT,
                RelativeLayout.LayoutParams.FILL_PARENT));
        }
    }
    

    With this code it is possible to get View from application B from using application A.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm struggling to get association right on Grails. Let's say I have two domain
So im struggling with the idea of implementing MVC pattern on a (lets say)
I really have no idea why I'm struggling with this so much. I'm scraping
been struggling with an issue now for a day or two. I have an
Possible Duplicate: Highlight keywords in a paragraph I have been struggling with the idea
I'm struggling with getting Linq To NHibernate to work. I have referenced NHibernate, NHibernate.Linq
I'm still struggling a bit with the idea of ARC. Let's suppose I have
I am really struggling with this and I have no idea why. I want
I've been struggling with this for hours and i have no idea why is
While I'm still struggling to find a solution for this question, i have another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.