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

  • Home
  • SEARCH
  • 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 8151805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:30:37+00:00 2026-06-06T15:30:37+00:00

I am new to android..Actually iam trying to increase the RAM Memory of android

  • 0

I am new to android..Actually iam trying to increase the RAM Memory of android phone through my app..For that I had created an activity from which i could Launch the other applications present in our phone.This approach is sucessfully reducing RAM memory.But i am facing a difficulty,as i couldnot see the PARENT activity after the launch of the Application. I need to push the other activities (that are launched) to be run in the background as soon as it has been launch and always i need the Parent activity to be visible..

package com.android;

import java.util.List;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.os.Handler;
import android.widget.LinearLayout;
import android.widget.Toast;
/**
 * GraphViewDemo creates some dummy data to demonstrate the GraphView component.
 * @author Arno den Hond
 **/
public class VsActivity extends Activity {
  /**
     * Variable Array for GraphView
     * verlabel : Background Height Values
     * horlabel : Background Width Values
     * values : Max Values of Foreground Active Graph
     */
    private float[] values = new float[60]; 
    long availableMegs;
    private String[] verlabels = new String[]     { "500","450","400","350","300","250","200","150","100","50","0"};
    private String[] horlabels = new String[] {"0","10", "20", "30", "40", "50", "60"};
    private GraphView graphView;
    private LinearLayout graph;
    private boolean runnable = false;
    public static int datasend,test=0;
    int cnt=0;
    Activity activity = this.activity;
    static int count=0;
    @Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        graph = (LinearLayout)findViewById(R.id.graph);
        graphView = new GraphView(this, values, "TEST GRAPH", horlabels, verlabels,    GraphView.LINE);
        graph.addView(graphView);
        runnable = true;
        startDraw.start();
    }

    @Override
    public void onDestroy(){
        super.onDestroy();
        runnable = false;
    }

    public void setGraph(){
        int i,j;
        count=count+10;
        try{
                j=values.length-1;
        for(i=0; i<values.length-1; i++){
            values[i] = values[i+1];
        }
        MemoryInfo mi = new ActivityManager.MemoryInfo();
        ActivityManager activityManager = (ActivityManager) getApplicationContext()
            .getSystemService(ACTIVITY_SERVICE);
        activityManager.getMemoryInfo(mi);
        datasend= (int)((mi.availMem / 1048576));
 values[values.length-1] = (float) datasend;        
graph.removeView(graphView);
        graph.addView(graphView);
        }
        catch (Exception e){
            // e.printstacktrace();
        }
    } 

private void  launchComponent(String packageName, String name){
    System.out.println("launch application "+datasend);
    Intent launch_intent = new Intent("android.intent.action.MAIN");
    launch_intent.addCategory("android.intent.category.LAUNCHER");
    launch_intent.setComponent(new ComponentName(packageName, name));
    launch_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    if(datasend > 24){
        System.out.println("launch application inside if "+packageName+"   "+name);
    this.startActivity(launch_intent);
    }
}

public void startApplication(){
    String application_name = "";
    test=1;
    //ContextWrapper activity = this.activity;
    try{
        System.out.println("Start application ");
        Intent intent = new Intent("android.intent.action.MAIN");
        intent.addCategory("android.intent.category.LAUNCHER");
        List<android.content.pm.PackageInfo> packageList;
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        PackageManager pm = this.getPackageManager();
        packageList = pm.getInstalledPackages(0);
        List<ResolveInfo> resolveinfo_list = pm.queryIntentActivities(intent, 0);

        for(ResolveInfo info:resolveinfo_list){
            application_name = info.activityInfo.packageName;
            System.out.println(info.activityInfo.packageName+"    "+info.activityInfo.name);
            //if(info.activityInfo.packageName.equalsIgnoreCase(application_name)){
                launchComponent(info.activityInfo.packageName, info.activityInfo.name);
              //  break;
           // }
        }
    }
    catch (ActivityNotFoundException e) {
        Toast.makeText(activity.getApplicationContext(), "There was a problem loading the application: "+application_name,Toast.LENGTH_SHORT).show();
    }
}
public Handler handler = new Handler(){
    @Override
    public void handleMessage(android.os.Message msg){
        switch(msg.what){

        case 0x01:
           setGraph();
          // if(test == 0){
          startApplication();//}
           break;
        }
    }
};

public Thread startDraw = new Thread(){
    @Override
    public void run(){
        while(runnable){
            handler.sendEmptyMessage(0x01);
            try{
                MemoryInfo mi = new ActivityManager.MemoryInfo();
                ActivityManager activityManager = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
                activityManager.getMemoryInfo(mi);
                long ava = mi.availMem / 1048576L;
                //count=(int)ava;
                //System.out.println("SUDARHAN RAMAN    "+ava+"   "+count);
                Thread.sleep(1000);
            } catch (Exception e){
                // e.printstacktrace();
            }
        }
    }
};
}

Here the GraphView is a View which will draw a Graph using Canvas.drawline(…)
In the above code startapplication() will launch the child (application installed in our phone) activities..

Plz help …

  • 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-06T15:30:38+00:00Added an answer on June 6, 2026 at 3:30 pm
         Intent i = new Intent(Intent.ACTION_MAIN);
                PackageManager manager = mContext.getPackageManager();
                i = manager.getLaunchIntentForPackage(_AppPkgName);
                i.addCategory(Intent.CATEGORY_LAUNCHER);
                startActivity(i);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Actually i am new in android. I want to create an simple app that
I am new android app developer i want make app for tablets and phone
I am trying to develop my first Android app through the ADT plugins for
I'm trying to get into Android app developing. My first problem is actually getting
I'm trying to create an Android client for a client/server app that has previously
I am a new android app developer and i want to use google map
I am trying to connect Unity with simple Java android development and I actually
When creating a new Android AVD through command line through the following command: android
I am working on an android app that has two activities. One is the
I am new to Android Development. Actually, I haven't started yet because I always

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.