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 7824569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:38:35+00:00 2026-06-02T08:38:35+00:00

I am creating a home automation app that has allows plugin views. I have

  • 0

I am creating a home automation app that has allows plugin views. I have been able to create a class as a sample plugin in a separate project (apk):

public class MyTestClass_IRDroidUIPlugIn extends Button implements IRDroidInterface{
    Context mContext;
    public MyTestClass_IRDroidUIPlugIn(Context context) {
        super(context);
        mContext = context;
        setText("I was loaded dynamically! (1)");
        setOnClickListener(new View.OnClickListener() {  
            public void onClick(View v) {  
                    // how do I show the dialog from here? 
                Activity.showDialog(1);
            }}  
                );
    }
    public Dialog buildConfigDialog(int ID){
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setMessage("Click the Button...(1)")
           .setCancelable(false)
           .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
               public void onClick(DialogInterface dialog, int id) {
                    dialog.dismiss();
               }           
           });
        return builder.create();
    }

}

I can load this class at run time and create an instance of it:

        try {
        final File filesDir = this.getFilesDir();
        final File tmpDir = getDir("dex", 0);
        final DexClassLoader classloader = new DexClassLoader( filesDir.getAbsolutePath()+"/testloadclass.apk",
                tmpDir.getAbsolutePath(),
                null, this.getClass().getClassLoader());
        final Class<View> classToLoad = 
                (Class<View>) classloader.loadClass("com.strutton.android.testloadclass.MyTestClass_IRDroidUIPlugIn");
        mybutton = (View) classToLoad.getDeclaredConstructor(Context.class).newInstance(this);
        mybutton.setId(2);
        main.addView((View)mybutton);
      } catch (Exception e) {
        e.printStackTrace();
    }

    setContentView(main);
}
protected Dialog onCreateDialog(int id) {
    switch (id) {
        case 1:
            return ((IRDroidInterface) mybutton).buildConfigDialog(id);
    }
    return null;
}

I want the plugin to be able to show a configuration dialog. Is there a way I can pass the Activity object to this class so it can use .showDialog(ID). This would be ideal so that the dialog life cycle can be managed properly.

Thanks in advance.

  • 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-06-02T08:38:36+00:00Added an answer on June 2, 2026 at 8:38 am

    Maybe I’m missing something, but why can’t you do something like this?

    public class MyTestClass_IRDroidUIPlugIn extends Button implements IRDroidInterface{
        Activity mContext;
        public MyTestClass_IRDroidUIPlugIn(Activity context) {
            super(context);
            mContext = context;
            ...
            setOnClickListener(new View.OnClickListener() {  
                public void onClick(View v) {  
                    mContext.showDialog(1);
                }}  
    
            );
    
    .....
    }
    

    When you’re creating this class, you’re already passing Activity into this class – so just use it.

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

Sidebar

Related Questions

I am creating a home automation app that has allows plugin views. I have
I am creating a application in I have a home screen. On that home
I'm creating a windows insaller for app that wll write some files to home
I'm creating an application which has a home screen that looks like the native
I'm creating a little photo sharing site for our home's intranet, and I have
I am creating a replacement Car Home app for Android 2.0+ devices. The app
I am creating an app with thumbnail views of my content. I would like
I am creating a reference app which has a navigation bar at the top
I am creating a GUI in which my home page has a button labelled
I follow this tutorial to create a svn http://www.guyrutenberg.com/2007/10/29/creating-local-svn-repository-home-repository/ However after running $ svn

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.