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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:06:37+00:00 2026-06-15T18:06:37+00:00

i have the following piece of code : package com.example.task; import java.util.List; import android.os.Bundle;

  • 0

i have the following piece of code :

package com.example.task;

import java.util.List;

import android.os.Bundle;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainTask extends Activity {

private Button BprocessesShow;
private TextView processesShow;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_task);

    ActivityManager manager =       (ActivityManager)getSystemService(ACTIVITY_SERVICE);
     final List<ActivityManager.RunningAppProcessInfo> runningProcesses = manager.getRunningAppProcesses();


    BprocessesShow=(Button) this.findViewById(R.id.BshowProcesses);
    processesShow=(TextView) this.findViewById(R.id.showProcesses);     


    BprocessesShow.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {


            processesShow.setText((CharSequence) runningProcesses);
        }
    });

}




@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_main_task, menu);
    return true;
}

}

well all i want to do is, when the user presses the button i made i want to show him/her all the running processes that has on his phone …When i’m running this application on my cellphone the app crashes and all i get is a message Unfortunately Task(that’s my name’s app) has stopped…Any help would be very useful!!

  • 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-15T18:06:39+00:00Added an answer on June 15, 2026 at 6:06 pm

    In this line

    processesShow.setText((CharSequence) runningProcesses);
    

    you are casting a List into a CharSequence. Try something along these lines:

    StringBuilder b = new StringBuilder();
    for (ActivityManager.RunningAppProcessInfo process: runningProcesses) {
        b.append(processs.processName);
        b.append("\n");
    }
    processesShow.setText(b.toString());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following piece of code for reversing the linked list. I am getting
I have following piece of code: customObject* object; std::list<customObject> objects; for(int i = 0;
I have following piece of code from my Backbone project: App.Controllers.Test = Backbone.Router.extend({ routes:
I have following piece of code: It compiles without problems under gcc-3.4, gcc-4.3, intel
I have following piece of code : public Hashmap<String,String> tempmap = new HashMap<String,String>(); and
I have the following piece of code that takes in some words, stores them
I have the following piece of code in my Model: public function getSite() {
I have the following piece of code where i am concatenating events to the
I have the following piece of code and in the j for loop the
I have the following piece of code which outputs a long article: <?php the_content();

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.