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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:03:44+00:00 2026-05-27T17:03:44+00:00

I created a PhoneGap plugin for android which sends an email . public PluginResult

  • 0

I created a PhoneGap plugin for android which sends an email.

public PluginResult execute(String action, JSONArray args, String callbackId) {
    try {
        // i want to call a function from other class so i did the
        // below, but it is throwing  the above said error...

        WebActivity wb = new WebActivity();
        wb.createExternalStoragePrivateFile(img);

        //sending email code here
    }
}

In above code while accessing the function of another class , i am getting the error:

cannot create handler inside thread that has not called Looper.prepare() error.

What is the right approach to call the function?

  • 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-27T17:03:45+00:00Added an answer on May 27, 2026 at 5:03 pm

    If WebActivity is actually an activity (i.e. extends Activity), you have several things wrong.


    You must not create Activity objects yourself. Well, you can, but than you have to assign a context to them (which I’m not sure even possible without using internals), and manage Activity lifecycle.

    You can’t just create an Activity object and call a function. This function may have lifecycle and context dependencies (i.e. you may have to “resume” the activity).


    The error you see is the result of that each Activity expects to be called from UI-thread ( or at least from Looper thread). The function you call most like uses Handler in some way, either directly or indirectly. And when this function creates a Handler and then posts a message or Runnable you’ll get the error you see.

    But again, this is because Activity is not meant to be used the way you’ve used. You cannot just create activity and start calling it’s method. You basically violate it’s state model. So Activity is not even supposed to work.


    As a solution, if you have control over WebActivity, move createExternalStoragePrivateFile() function into some independent class or make it static (if possible), or both. You most likely will need to fix a thing or two there, to make it work. But at least you’ll be able to call the function from other places.

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

Sidebar

Related Questions

My issue is regarding PhoneGap and Android development using the Eclipse Applaud plugin. I
I am developing application using phonegap in eclipse for android .I have created folder
I've created one Android app with Phonegap. I want to hide default notification bar
I'm working on making a Phonegap plugin for Android. When I add the findViewById
I have created a simple application in android [PhoneGap] [Eclipse] {Sorry for this convention
In android phonegap application, I created 5 or more question with respective option (checkboxes)
Is there a workaround or a phonegap plugin using which its possible to create
I am using phonegap for IOS. I created a Plugin to unzip files. But
I created dynamic list using android phonegap application.Now I want to add scrollbar for
I created a dynamic list with hyperlinks using Android PhoneGap . Now I want

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.