0

This question isn't a "How can I make an Android launcher?". I would like to know, how can I add a home-screen to my application.

My app has a mainscreen, then a App drawer. the Mainscreen has fixed displayed content. And the App drawer, just shows my app. So I would like to know how can I go about adding a homescreen to my application, where when I swipe left the home screen appears.

I've tried searching but all there is how to make launchers, but looking through the code I'm not exactly sure what .java file I'm supposed to actually look at. So i'm finding it hard to implement this.

If you know how can I go about doing the above please give me some tips, and sample or source that I can work with or even to just take a look at so I have an idea.

Thank you for your time.

SmallVille
  • 87
  • 8

1 Answers1

1

Use this code for launching the home screen

PackageManager pm = getPackageManager();
Intent i = new Intent("android.intent.action.MAIN");
i.addCategory("android.intent.category.HOME");
List<ResolveInfo> lst = pm.queryIntentActivities(i, 0);
if (lst != null) {
   for (ResolveInfo resolveInfo : lst) {
       try {
       Intent home = new Intent("android.intent.action.MAIN");
       home.addCategory("android.intent.category.HOME");
       home.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name);
       startActivity(home);
       break;
       } catch (Throwable t) {
           t.printStackTrace();
       }
   }
}

from the answer provided here And for the swipe left action you need to add some gestures or something in your code,

Community
  • 1
  • 1
insomniac
  • 11,146
  • 6
  • 44
  • 55
  • thanks for the code and the reference, sadly when I add the code to my launcher it doesn't do anything, no error, changes or anything? – SmallVille May 07 '14 at 10:23