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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:02:00+00:00 2026-06-14T11:02:00+00:00

I am new to Java & Android development, but I have been able to

  • 0

I am new to Java & Android development, but I have been able to create a mess of functions, subclasses & constants that work perfectly fine when pasted inside the MainActivity class of a default Android project.

The purpose of these functions is to “ping home” to let my servers know when an application install has occurred. The only code that is needed to make this happen is the line notifyMyServer() inside this standard block of code of MainActivity.java:

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        notifyMyServer("install"); /* Notify MyServer of an Installation */

    }
}

Pasting the functions, subclass, constants and imports that make notifyMyServer() work directly inside the MainActivity.java file seems dirty to me. I would love to be able to move them to their own file and/or library so I could drag & drop that file into other apps I want to do perform the same tracking on.

How is this typically done?

  • 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-14T11:02:01+00:00Added an answer on June 14, 2026 at 11:02 am

    Take your notify code and create an class which just performs this notification (can be part of a library or not):

    public class NotifyingActivity extends Activity {
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            notifyMyServer("install"); /* Notify MyServer of an Installation */
        }
    }
    

    And then in your MainActivity, just inherit from NotifyingActivity instead of Activity. Then the notification will automatically happen when you call super.onCreate() inside of MainActivity.

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

Sidebar

Related Questions

I'm new to Android & Java programming but have been programming in .NET for
I am new to Android development and i have been asked to create an
I'm fairly new to Java & Android, so I have little idea what I
I'm new to Android and Java. I have been working on my task i.e,
I started a new job recently. I've been a Java & XML web developer
I'm new to Java and Android development so I decided to make a simple
I have been slowing learning and building my first android app. I'm VERY new
I have a java server that sends files to an android client. for some
I am using android.text.format.DateFormat.format(yyyy-MM-dd hh:mm:ss, new java.util.Date()) to get time & date. The problem
I'm fairly new to Android development and I can't seem to grasp the Java

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.