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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:56:15+00:00 2026-06-17T08:56:15+00:00

My android app uses a single Activity which creates a single SurfaceView which is

  • 0

My android app uses a single Activity which creates a single SurfaceView which is not defined in the manifest, and all of my UI elements are custom. Now I’m trying to make an asynchronous HTTP call and I can’t access any of my application’s classes. Every example I’ve seen for an async http call looks something like this:

class RequestTask extends AsyncTask<String, String, String>{

    @Override
    protected String doInBackground(String... uri) {
        // Code to make http call
        return responseString;
    }

    @Override
    protected void onPostExecute(String result) {
        super.onPostExecute(result);
        TextView txt = (TextView) findViewById(R.id.output);
        // format the result and write it to the TextView object
    }
}

In that example, since the RequestTask doesn’t have access to any application objects, you get at them with findViewByID. What I don’t understand is, how can I access my application’s objects if I don’t have any Views defined in my manifest? The only thing in my manifest is the Activity:

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <activity
        android:name="com.blah.blah.MyActivity"
        android:label="@string/app_name" >
        android:configChanges="keyboardHidden|orientation" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

I did this for simplicity/laziness and it’s worked fine so far. Is there a way to access my application (either the activity, or the views defined in it, or other classes I’ve instantiated) without using findViewById, or do I need to define my SurfaceView in the manifest?

  • 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-17T08:56:16+00:00Added an answer on June 17, 2026 at 8:56 am

    Add a constructor to the task. Pass in the view it needs to access in the constructor. Save it to a class variable of the task.

    If you need to do a lot of them, pass in the activity, and call findViewById on the activity. Just remember to null out the activity at the end of the onPostExec, to avoid the risk of leaking the activity.

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

Sidebar

Related Questions

I have an Android app which includes an activity called Help This uses a
I am currently working on a single activity Android app that uses a lot
I have a custom view in my Android App that uses a ScaleGestureDetector.SimpleOnScaleGestureListener to
Problem: I am building Android app in Eclipse which uses shared lib libgstreamer-0.10.so (GStreamer-android
I have an Android app which uses a service to continuously update a textview
I am working on an android app that uses google maps. now I would
I'm working on an android app which at a point uses a DatePicker widget,
Im developing an Android App which uses the new Facebook 3 SDK. I make
Im creating an android app which uses a menu.xml file in the res folder.
I have an Android app which uses Jackson parser for JSON parsing. After I've

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.