Intent to pick an installed application slow in my activity, why?
If you long press on your homescreen and pick to add an application shortcut, you will be greeted with a listview showing all of your instal applications. I needed this same functionality in my application so I copied the intent from the launcher source:
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY);
pickIntent.putExtra(Intent.EXTRA_INTENT, mainIntent);
this.startActivityForResult(pickIntent, MoreIconsConstants.REQUEST_PICK_APPLICATION)
When this executes on the launcher it is pretty speedy. When I execute this in my activity it takes maybe 15 seconds instead of 3. It seems like the launcher must be caching this data for some amount of time? Is there any way I can cache the data too?
Thanks!
Asked by: Ryan871 | Posted: 25-01-2022
Answer 1
You can read all the apps that install by this code
final PackageManager pm = a.getPackageManager();
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List<ResolveInfo> apps = pm.queryIntentActivities(mainIntent, 0);
Collections.sort(apps, new ResolveInfo.DisplayNameComparator(pm));
for (int i = 0; i < apps.size(); i++)
{
ResolveInfo info = apps.get(i);
//Intent to start the app
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(new ComponentName(info.activityInfo.applicationInfo.packageName,info.activityInfo.name));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
//Load app icon
info.activityInfo.loadIcon(pm)
//Load app label
info.loadLabel(pm)
}
Check this example code http://developer.android.com/resources/samples/Home/src/com/example/android/home/Home.html search for loadApplications function
I had the same problem so what I did is to load the application by the code above in a thread.
Answered by: Tara104 | Posted: 26-02-2022Similar questions
android - Launch installed application with launch activity null
I am using the following code to get a list of installed applications and launch them.It only opens application like calculator or clock.When i try to open applications like contacts or camera it does not work as their launch activity is null.How do i open such applications.
In the below code s[5] points to the camera.
final PackageManager pm = getPackageManager();
List<ApplicationInfo...
android - Can I add widgets from installed apps to my application activity
I am trying develop an android application for a device (device is not a tablet or phone, its a preconfigured android board running Android 4.1.1)and one of the activity need to display a customized dashboard of several types of information as shown below
The types of information shown here is preconfigured. Instead of developing all...
How to display lock activity quickly when user click on another installed application in android
I'm trying to open lock activity while opening another installed app. Its working fine. Lock activity does open, but it opens after another application launches. So how to open lock activity before another application launches? If anyone have solution then help me.Through searching i search code that get foreground task in andr...
android - Can't find my installed application
Greets,
Made some app on android. I for the life of me can't get it to install on the phone as a stand alone application. It runs fine when I deploy from eclipse but never remains on the device. any idea whats happening?
I put the apk file on a web server, went to the address downloaded and installed but still it wasn't to be found.
I'm lost!
android - Where to place the resources of her application so that they are installed on the SD card?
I have big files to integrate into my application (videos), and thus for not not that my application occupies all the internal memory of the telephones, I saw that it was possible with Froyo to install the applications on the SD card.
I thus have to test this solution and my application settles down well on the SD card, the only problem it is that the system installs all the same my files videos (which are placed i...
android - Display route between two points in installed application
How to showActivity which will display route between two points.
This will start installed map application on android phone.
android - How to find whether an application is installed in a device from web?
I created an android application and uploaded in my website. Is it possible to check from the web whether this application is installed in the device when someone is trying to download the application ? If it is installed, the user should get a prompt whether to reinstall or not. If not the application should not be downloaded.
Thanks in advance...
regards,
Vishakh
android - Application not installed on phone
I have samsung i5503 galaxy. I got a problem in developing app.
First I attach the phone with pc and turn usb debugging on,install the driver than as i run my app ,my phone is not appeared as running android device. So how can i run and test my app on real device?
Secondly i make apk of my app and than mail it than i open this mail n my phone and try to install the app but error was app not installed.
What ...
java - Event when application gets installed (Android)
Is there any event triggered when the application is finished installed in the phone.I have seen some post but no luck ,there were similar question asked but no answer was found.
Any help would be appreciated.
Thanks in advance.
Multiple Application Icons Are Installed On Phone When Running Androids App
I am developing an android app w/ Eclipse. Whenever I run the app on my phone or the emulator, four application icons are installed on the device. I am guessing it is related to my manifest file which has three activities (3 are for tabs).
When I uninstall the app, all of the icons are removed from the phone. Upon a reinstall, all four show back up.
<?xml version="1.0" encoding="utf-8"?>
&l...
android - Way to know if my application is installed
Is there any way (intent) to know if my application is installed ?
I followed the below link, but my application don't get the intent when my app is installed
Android - How to intercept the 'Install application' intent
How to get the path of android installed application
Hi I am new to Android and I want to know that how can we get the path of the installed application in android, So that we can open the file in our application by using that installed application.
for example:
I want to open the pdf file or doc file in my application but i require the path of that application which can open this file...
Please Help me
Thanks in advance...
why android application could not be installed on HTC Tattoo?
Hi I am newly started work on android. But when I tried to install my application on Android Tattoo it shows error
application could not be installed on phone.
Can anyone help me!
android application memory leaks
I am using kind of results search engine, problem is to remember the searching criteria i made singleton static class which keeps only one instance.
In my application there are lots of class level private variables, lots of public static variables, a big util class which contains only static final methods.
problem is my application get crash any time any where any spot and interesting thing is crash code a...
Android Application data should not be released by android OS
public class MYApplication extends Application {
String property;
setter getter
}
does above code make sure property will not be collectied by android OS if not used for a long period of time.
Android Email application - Is it possible to get all the details which are configured in Email application
Is there any way to get in the code:
Email id
Password
SMTP host
SMTP port
which the user used to setup his Email account with the Android built in Email application
Required because, I am written a MailSender class using JavaMail API there I need to send the mail using the details what user configured in Built in Android Email application.
Android Intent for Twitter application
Is it possible to show a list of applications (with intent.createChooser) that only show me my twitter apps on my phone (so htc peep (htc hero) or twitdroid). I have tried it with intent.settype("application/twitter") but it doesnt find any apps for twitter and only shows my mail apps.
Thank you,
Wouter
webserver - Retrieve data from a web server for android application
I am developing an application that needs to retrieve some data from a web server. But I have no idea how can this be possible?
Should a legacy Android application be rebuilt using SDK 2.1?
I have an Android application that uses the well known Strategies for Legacy Applications. It is build with the Android SDK 2.0 with manifest settings minSdkVersion="3" (API 1.5) and targetSdkVersion="5" (2.0). Question1: Since maxSdkVersion is not specified, the application should be...
web services - How to store data accessible to both a web site and android application?
I’m developing an Android and web application that will function as a service (use the same data).
My question is how should the data be stored to allow for both the web and the android application to have access to the same set of data?
Should the android application connect to the sites MySQL server to store/access data?
If so how do I allow someone to access the data when they are not in ...
Android 1.6 SMS (older application code)
I have HTC Tattoo with Android 1.6. I have maed a Java program for SMS sending. I got the source on the Internet, I think, versions before 1.6. The problem is: SMSs are sent twice.
What is a possible cause for this problem?
If possible, please simply post sample code what works OK.
How to close Android application?
I want to close my application, so that it no longer runs in the background.
How to do that? Is this good practice on Android platform?
If I rely on the "back" button, it closes the app, but it stays in background. There is even application called "TaskKiller" just to kill those apps in the background.
listview - android application failing upon user scrolling - no 'obvious' error
I'm having a strange problem with Android 1.6
I have an application that has a ListView (found in Activity #1).
The user can click on one of the rows in the ListView and is taken to a 2nd Activity (Activity # 2).
User can then use the back button to go back to the ListView.
The problem is that if the user scrolls down the list after returning from Activity # 2 the application crashes, bu...
Still can't find your answer? Check out these communities...
Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android