Android Open Source - HomeSwipeManager App






From Project

Back to project page HomeSwipeManager.

License

The source code is released under:

Apache License

If you think the Android project HomeSwipeManager listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/* Copyright 2013 Andrea De Cesare
*// w  ww  .j av a 2  s .co  m
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.andreadec.homeswipemanager;

import java.util.*;
import android.content.*;
import android.content.pm.*;
import android.graphics.drawable.*;

public class App {
  public String name;
  public String packageName;
  public String label;
  public Drawable icon;
  
  public App(String name, String packageName, String label, Drawable icon) {
    this.name = name;
    this.packageName = packageName;
    this.label = label;
    this.icon = icon;
  }
  
  /**
   * Builds a list of all the applications installed on the device
   * which can be launched from the launcher's apps drawer
   * @param context
   * @return
   */
  public static ArrayList<App> getApps(Context context) {
    ArrayList<App> apps = new ArrayList<App>();
    PackageManager packageManager = context.getPackageManager();
    final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null).addCategory(Intent.CATEGORY_LAUNCHER);
    List<ResolveInfo> activities = packageManager.queryIntentActivities(mainIntent, 0);
    String name, packageName, label;
    Drawable icon;
    for(ResolveInfo activity : activities) {
      name = activity.activityInfo.name;
      packageName = activity.activityInfo.packageName;
      label = activity.loadLabel(packageManager).toString();
      icon = activity.loadIcon(packageManager);
      apps.add(new App(name, packageName, label, icon));
    }
    Collections.sort(apps, new Comparator<App>() { // Sorts the applications by name
      @Override
      public int compare(App a1, App a2) {
        return a1.label.compareToIgnoreCase(a2.label);
      }
    });
    return apps;
  }
}




Java Source Code List

com.andreadec.homeswipemanager.Action.java
com.andreadec.homeswipemanager.App.java
com.andreadec.homeswipemanager.AppsArrayAdapter.java
com.andreadec.homeswipemanager.HomeSwipeManagerApp.java
com.andreadec.homeswipemanager.MainActivity.java
com.andreadec.homeswipemanager.SettingsActivity.java