• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.launcher3;
18 
19 import android.content.Intent;
20 import android.os.Bundle;
21 
22 import java.io.FileDescriptor;
23 import java.io.PrintWriter;
24 
25 /**
26  * LauncherCallbacks is an interface used to extend the Launcher activity. It includes many hooks
27  * in order to add additional functionality. Some of these are very general, and give extending
28  * classes the ability to react to Activity life-cycle or specific user interactions. Others
29  * are more specific and relate to replacing parts of the application, for example, the search
30  * interface or the wallpaper picker.
31  */
32 public interface LauncherCallbacks {
33 
34     /*
35      * Activity life-cycle methods. These methods are triggered after
36      * the code in the corresponding Launcher method is executed.
37      */
onCreate(Bundle savedInstanceState)38     void onCreate(Bundle savedInstanceState);
onResume()39     void onResume();
onStart()40     void onStart();
onStop()41     void onStop();
onPause()42     void onPause();
onDestroy()43     void onDestroy();
onSaveInstanceState(Bundle outState)44     void onSaveInstanceState(Bundle outState);
onActivityResult(int requestCode, int resultCode, Intent data)45     void onActivityResult(int requestCode, int resultCode, Intent data);
onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)46     void onRequestPermissionsResult(int requestCode, String[] permissions,
47             int[] grantResults);
onAttachedToWindow()48     void onAttachedToWindow();
onDetachedFromWindow()49     void onDetachedFromWindow();
dump(String prefix, FileDescriptor fd, PrintWriter w, String[] args)50     void dump(String prefix, FileDescriptor fd, PrintWriter w, String[] args);
onHomeIntent(boolean internalStateHandled)51     void onHomeIntent(boolean internalStateHandled);
handleBackPressed()52     boolean handleBackPressed();
onTrimMemory(int level)53     void onTrimMemory(int level);
54 
55     /**
56      * Called when the launcher state changed
57      */
onStateChanged()58     default void onStateChanged() { }
59 
60     /*
61      * Extension points for providing custom behavior on certain user interactions.
62      */
onLauncherProviderChange()63     void onLauncherProviderChange();
64 
65     /**
66      * Starts a search with {@param initialQuery}. Return false if search was not started.
67      */
startSearch( String initialQuery, boolean selectInitialQuery, Bundle appSearchData)68     boolean startSearch(
69             String initialQuery, boolean selectInitialQuery, Bundle appSearchData);
70 }
71