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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:22:42+00:00 2026-06-13T10:22:42+00:00

Imagine that I have a camera app where I show a small MapView in

  • 0

Imagine that I have a camera app where I show a small MapView in one corner showing where is the device located. So I have to extend my activity from a MapActivity to do that.

Then imagine that I want to release my app in a device without Google Apis, like the Kindle, for instance. As the MapActivity does not exist anymore, I should extend from a regular Activity.

I know that I can set

<uses-library
        android:name="com.google.android.maps"
        android:required="false" />

To let the user install the app even if the library is missing. And then use

    try {
        Class.forName("com.google.android.maps.MapView");
        googleMapsEnabled = true;
    } catch( ClassNotFoundException e ) {
        googleMapsEnabled = false;
    }

to check if the MapView class is present or not.

But the problem is the base class that I extend from, it should be Activity instead of MapActivity if Google Maps are not available.

My question is, how can I use the same code to support both options, without duplicating the whole code into different classes depending on the installed libs?

  • 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-13T10:22:43+00:00Added an answer on June 13, 2026 at 10:22 am

    For what it’s worth, my usual approach with things like this (ie: where I have to inherit from two different base classes in different scenarios, but ultimately want the same – or nearly the same – behavior) is to break out as much as I can of the common functionality into a static helper class that I call from both classes.

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

Sidebar

Related Questions

Situation: Imagine that I have an item(page) located at 'sitecore/Content/Home/mypage' in my content tree.
Imagine that I have a form in a flash application with two fields, input1
Imagine that I have a nice Deck class, in the best OO fashion. It
Imagine that i have the following code: <a:repeat value=#{bean.getList()} var=x > <li class=la> <span>
imagine that I have a Form with 9 controls (TabbedStuffControl) in a 3x3 tile,
Let's imagine that I have to make a table with the following structure with
Let's imagine that I have list of files at host1 find /path/to -name *.jpg
Let's imagine that I have a result of evaluating XPath expression //node/@*. MSXML6 returns
I would like to ask you: Imagine that you have a site and there
I am using Entity Framework and DevExpress 10.5 XtraGrid. Imagine that we have entities

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.