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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:49:48+00:00 2026-05-29T19:49:48+00:00

I hope this is the appropriate title for this question. Right now I have

  • 0

I hope this is the appropriate title for this question. Right now I have two classes. A main class and a ApplicationOperations class. Initially I had a method uninstallapplication and listall installed applications which worked fine in my main class. Now as I move them to another class (in order to expand) they do not work. I do not know anything about intents as I am still a newbie so any help would be great!

I am getting an error on

PackageManager pm = getPackageManager(); <--method undefined???
      and
StartActivity <---method undefined. 

Here is the Code. Please let me know if you need anything else:

MAIN FILE:

package com.IPR2.viewlog;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;



public class Main extends Activity {
    private TextView tv;

    /** Called when the activity is first created. */


    @Override
    public void onCreate(Bundle savedInstanceState) {
        FileOperations fileOperations = new FileOperations();
        ApplicationOperations applicationOperations = new ApplicationOperations();
        Testing testing = new Testing();
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        tv = (TextView) findViewById(R.id.TextView01);



    }



}

ApplicationOperations.java

package com.IPR2.viewlog;

import java.util.List;

import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.util.Log;

public class ApplicationOperations {

    FileOperations fileOperations = new FileOperations();

    public void UninstallApplication(String packageName)
{
    Uri packageURI = Uri.parse("package:"+packageName);
    Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
    startActivity(uninstallIntent);
}

    public void ListAllInstalledApplications()
{       
    PackageManager pm = getPackageManager(); 
    //get a list of installed apps. 
            List<ApplicationInfo> packages = pm 
                    .getInstalledApplications(PackageManager.GET_META_DATA); 
            for (ApplicationInfo packageInfo : packages) 
            { 
                fileOperations.AppendFile("Installed package :" + 
                        packageInfo.packageName + "\n", "Installed_packages.txt");
//              tv.append("Installed package :" + packageInfo.packageName + "\n");  
            }
} 

}
  • 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-29T19:49:49+00:00Added an answer on May 29, 2026 at 7:49 pm

    When your code

    PackageManager pm = getPackageManager();
    

    Was inside the Class inherited from Activity class (class Main), it worked because in fact getPackageManager() is Context.getPackageManager. Activity extends Context class, hence everything is okay.
    But you moved this code into new class which doesn’t extend anything related to Context. Hence you have a compile error.
    You should pass somehow a context into your new class (ApplicationOperations) and use it

    PackageManager pm = mContext.getPackageManager()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry, couldn't find a more appropriate title. In My code I have two classes
I'm not sure this question is appropriate here but I hope I could get
(I hope this is a valid question) As I stated in my title, I'm
ok, I hope the title of this question makes sense. In my app I
I hope this question is appropriate for stackoverflow... What is the difference between storing
I hope this question is considered appropriate for stackoverflow. If not, I'll remove the
I hope this is an appropriate question: I'm using the Netflix API and I'm
Hope this is the right place to be asking this, so my apologies if
hope this will be a quick easy question, I've just tried my app on
I hope this is allowed but I have a number of questions regarding Facebook

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.